我如何避免index.php从URL在codelgniter
问题描述:
我使用apache服务器,我需要从uri中删除index.php
I am using apache server,I need to remove index.php from uri
答
打开config.php并替换
Open config.php and replace
$config['index_page'] = "index.php" by $config['index_page'] = ""
在.htaccess文件中添加
In .htaccess file add
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
$ b b
在某些情况下,uri_protocol的默认设置无法正常工作。要解决这个问题,只需在config.php
In some cases the default setting for uri_protocol does not work properly. To solve this problem just replace in config.php
$config['uri_protocol'] = "AUTO" by $config['uri_protocol'] = "REQUEST_URI"