htacces,一些重写的​​网址给我错误404

时间:2016-03-15 16:07:12

标签: php apache .htaccess debian wamp

我在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/的规则上(不适用于任何事情) 你知道怎么解决吗?

1 个答案:

答案 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