.htaccess 使用htaccess文件删除ubuntu上codeigniter中的index.php

.htaccess 使用htaccess文件删除ubuntu上codeigniter中的index.php,.htaccess,codeigniter,mod-rewrite,.htaccess,Codeigniter,Mod Rewrite,使用安装在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

使用安装在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 rewrite。谢谢

这可能是因为ubuntu服务器设置为传递路径信息,这意味着您不需要查询字符串。您可能只需从规则中删除
,它就可以工作了:

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 ----------^

可能重复没有错误,除了我必须在控制器之前添加index.php,它才能工作。示例:不起作用,但起作用。奇怪的是,使用相同的配置,在安装在windows 7上的apache2上可以完美运行。您是否在
/etc/apache2/sites available/default
中将
AllowOverride None
更改为
AllowOverride All
?是的,我确实将AllowOverride None更改为AllowOverride All,重新启动了服务器,但仍然存在相同的问题