我在Debian 8中遇到一个htaccess文件有问题(它运行正常,我的wamp服务器一切正常):
RewriteBase /
#Remove trailing slash from url
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^action/(.*)$ action.php?action=$1 [QSA,L]
RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
像/index.php?path=login
这样的Debian网址中的变得正确/login
并且一切正常,但这不适用于index.php?path=index
这样的网址:重新设置的网址/index
显示错误404
同样的事情发生在action/
的规则上(不适用于任何事情)
你知道怎么解决吗?
答案 0 :(得分:3)
有这样的话:
Options -MultiViews
RewriteEngine On
RewriteBase /
#Remove trailing slash from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L,NE]
RewriteRule ^index\.php$ - [L,NC]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^action/(.*)$ action.php?action=$1 [QSA,L,NC]
RewriteRule ^(.*)$ index.php?path=$1 [QSA,L]
RewriteCond
仅适用于下一个RewriteRule
。