htaccess,一些重写 url 给我错误 404
htacces, some rewrited url give me error 404
我在 Debian 8 中遇到 htaccess 文件的问题(它运行良好,在我的 wamp 服务器中一切正常):
RewriteBase /
#Remove trailing slash from url
RewriteRule ^(.*)\/(\?.*)?$ [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= [QSA,L]
RewriteRule ^(.*)$ index.php?path= [QSA,L]
在 Debian url 中 /index.php?path=login
变得正确 /login
并且一切正常,但这不适用于 url 就像 index.php?path=index
:重写 url /index
显示错误 404。
action/
的规则也会发生同样的事情(这对任何东西都不起作用)。
你知道怎么解决吗?
像这样:
Options -MultiViews
RewriteEngine On
RewriteBase /
#Remove trailing slash from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ [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= [QSA,L,NC]
RewriteRule ^(.*)$ index.php?path= [QSA,L]
RewriteCond
只适用于下一个RewriteRule
.
我在 Debian 8 中遇到 htaccess 文件的问题(它运行良好,在我的 wamp 服务器中一切正常):
RewriteBase /
#Remove trailing slash from url
RewriteRule ^(.*)\/(\?.*)?$ [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= [QSA,L]
RewriteRule ^(.*)$ index.php?path= [QSA,L]
在 Debian url 中 /index.php?path=login
变得正确 /login
并且一切正常,但这不适用于 url 就像 index.php?path=index
:重写 url /index
显示错误 404。
action/
的规则也会发生同样的事情(这对任何东西都不起作用)。
你知道怎么解决吗?
像这样:
Options -MultiViews
RewriteEngine On
RewriteBase /
#Remove trailing slash from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ [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= [QSA,L,NC]
RewriteRule ^(.*)$ index.php?path= [QSA,L]
RewriteCond
只适用于下一个RewriteRule
.