使用安装在Windows 7上的Apache2,我使用下面的htaccess配置从codeigniter url中删除index.php:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
有人可以告诉为什么上面的配置在ubuntu上不起作用。 我使用 sudo a2enmod rewrite 启用mod重写。感谢
答案 0 :(得分:2)
这可能是因为ubuntu服务器设置为传递PATH_INFO,这意味着您不需要查询字符串。您可以从规则中删除?
,它应该可以正常运行:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
# no query string ----------^