codeIgniter从URL删除的index.php [英] CodeIgniter removing index.php from url
问题描述
我目前的URL看起来像这样 [mysite的]的index.php / [炉渣其余]
。
我想从这些URL条的index.php
。
的mod_rewrite
是我的Apache2服务器上启用。在配置
, $配置['index_page'] ='';
我的codeignitor根的.htaccess
文件包含,
RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。*的index.php / $ 0 PT,L]
但它仍然是行不通的。我在哪里的问题呢?
试试看。
打开config.php文件,并就以下内容替换
$配置['index_page'] =的index.php
至
$配置['index_page'] =
在某些情况下,默认设置uri_protocol不能正常工作。 只需更换
$配置['uri_protocol'] =AUTO
通过
$配置['uri_protocol'] =REQUEST_URI
的.htaccess
RewriteEngine叙述上
的RewriteCond $ l ^(指数\ .PHP |资源|机器人\ .TXT)!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]
My current urls look like this [mysite]index.php/[rest of the slug]
.
I want to strip index.php
from these urls.
mod_rewrite
is enabled on my apache2 server. In config
, $config['index_page'] = '';
My codeignitor root .htaccess
file contains,
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
But still it is not working. Where am I going wrong?
Try It.
Open config.php and do following replaces
$config['index_page'] = "index.php"
to
$config['index_page'] = ""
In some cases the default setting for uri_protocol does not work properly. Just replace
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"
HTACCESS
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
这篇关于codeIgniter从URL删除的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!