[英]htaccess not redirecting to custom 404
Everything on my page works except that non existing page is recognised as parameter and that displays page with header and footer.除了不存在的页面被识别为参数并且显示带有页眉和页脚的页面之外,我页面上的所有内容都可以正常工作。
ErrorDocument 404 /error
ErrorDocument 403 /error
ErrorDocument 500 /error
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?v=$1 [L,QSA]
RewriteRule ^(.*)-(.*)-(.*)$ index.php?v=$1&page=$2&folder=$3 [L,QSA]
When I try to open mydomain.com/non-existing-page than "non-existing-page" is recognised as parameter $v and page mydomain.com/index.php$v=non-existing-page is opened with only header footer and no content.当我尝试打开 mydomain.com/non-existing-page 时,“non-existing-page”被识别为参数 $v 并且页面 mydomain.com/index.php$v=non-existing-page 只打开了标题页脚,没有内容。
You can change .*
with [^/-]+
to allow only single parameter (non-slash+non-hyphen) to be handled by index.php
.您可以使用[^/-]+
更改.*
以仅允许index.php
处理单个参数(非斜杠+非连字符)。
You can use these rules:您可以使用以下规则:
ErrorDocument 404 /error
ErrorDocument 403 /error
ErrorDocument 500 /error
RewriteCond %{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([^/]+)-([^/]+)-([^/]+)/?$ index.php?v=$1&page=$2&folder=$3 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.