[英]Mod rewrite to redirect to 404
Current .htaccess 当前的.htaccess
RewriteEngine on
RewriteRule category-([0-9]+)-(.*)-([0-9]+)\.html$ category.php?cid=$1&name=$2&page=$3.php [L]
RewriteRule search-(.*)-([0-9]+)\.html$ search.php?term=$1&page=$2.php [L]
RewriteRule all-covers-([0-9]+)\.html$ all-covers.php?page=$1.php [L]
RewriteRule featured-covers-([0-9]+)\.html$ featured-covers.php?page=$1.php [L]
RewriteRule top-downloaded-([0-9]+)\.html$ top-downloaded.php?page=$1.php [L]
RewriteRule c-([0-9]+)-(.*)\.html$ cover.php?id=$1&name=$2.php [L]
RewriteRule ^sitemap.xml$ sitemap.php [L]
RewriteRule ^(.*)\.html$ $1.php [L]
ErrorDocument 404 /404.html
I want to redirect to 404 from pages like this: [http://example.com/http://example.com/c-42.html] 我想从这样的页面重定向到404:[http://example.com/http://example.com/c-42.html]
Help please 请帮助
The first thing you need to do is add ^
qualifiers to your regex patterns: 您需要做的第一件事是在正则表达式模式中添加
^
限定符:
RewriteRule ^category-([0-9]+)-(.*)-([0-9]+)\.html$ category.php?cid=$1&name=$2&page=$3.php [L]
RewriteRule ^search-(.*)-([0-9]+)\.html$ search.php?term=$1&page=$2.php [L]
RewriteRule ^all-covers-([0-9]+)\.html$ all-covers.php?page=$1.php [L]
RewriteRule ^featured-covers-([0-9]+)\.html$ featured-covers.php?page=$1.php [L]
RewriteRule ^top-downloaded-([0-9]+)\.html$ top-downloaded.php?page=$1.php [L]
RewriteRule ^c-([0-9]+)-(.*)\.html$ cover.php?id=$1&name=$2.php [L]
That means, for example, ^c-([0-9]+)-(.*)\\.html$
will match http://example.com/c-42.html
but will no longer match http://example.com/http://example.com/c-42.html
. 举例来说,这表示
^c-([0-9]+)-(.*)\\.html$
将与http://example.com/c-42.html
匹配,但不再与 http://example.com/http://example.com/c-42.html
匹配 http://example.com/http://example.com/c-42.html
。 And the latter will automatically end up as a 404. 后者将自动以404结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.