如何从URL中删除“ index.php”?

描述

使用CI构建简单的MySQL-Php应用程序,我无法摆脱URL内的“ index.php”标签:

localhost/CodeIgniter/index.php/Defult_Controller/index

.htaccess

application/.htaccessapplication/cache/.htaccess

<IfModule mod_rewrite.c>

# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
#  slashes.
# If your page resides at
#  http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/

RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>


apache.conf

LoadModule rewrite_module modules/mod_rewrite.so


application / config / config.php

$config['base_url'] = "http://localhost/CodeIgniter/";
$config['index_page'] = '';


PS:我正在使用codeIgniter 2.5.1和xampp 3.2.1

最佳答案

您需要将.htaccess放在根文件夹中以删除index.phpapplication/.htaccess是为了避免出现目录视图。

关于php - 摆脱CodeIgniter URL中的Index.php,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23966361/

10-13 06:38
查看更多