我有一个问题我使用一个.htaccess文件表单一年这个代码在所有服务器上工作但今天我有一个新服务器相同的代码不工作。我无法从URL中删除index.php。我的服务器是Apache / 2.2.15(Red Hat)。 我的.htaccess文件的代码
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
<IfModule mod_headers.c>
Header add Cache-Control: "no-store, no-cache, must-revalidate"
</IfModule>
在配置文件中,我设置了以下设置
$ config ['index_page'] =''; $ config ['uri_protocol'] ='自动';
此代码正在另一台服务器上运行
答案 0 :(得分:0)
你可以尝试这样:(但我不确定)
RewriteRule ^(.*)$ index.php/$1 [L]
我也在使用Apache。我的.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
答案 1 :(得分:0)
答案 2 :(得分:0)
确保您从apache启用了mode_rewrite,debian服务器可以运行a2enmod rewrite
尝试下面的htaccess,当我遇到同样的问题时,它对我有用
的.htaccess
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Goodluck:)
答案 3 :(得分:0)
使用以下代码:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我希望这会对你有所帮助。