将页面重定向到404

时间:2015-04-18 16:15:00

标签: .htaccess rewrite

我找到了一些页面,用于将单个页面重定向到404,但它无效。这是我的简单线

RedirectMatch 404 ^/showthread.php?p=3164554$

虽然不起作用。我错过了什么吗?谢谢!

2 个答案:

答案 0 :(得分:1)

您的配置尝试将页面“404”重定向到页面“^ / showthread.php?p = 3164554 $”(请参阅​​documentation)。

RedirectMatch生成重定向:您无法使用HTTP 404代码重定向。重定向时,您可能遇到查询字符串问题(我无法匹配查询字符串),我会使用重写规则:

您可以使用

重定向到404.html页面
RewriteEngine On
RewriteCond %{QUERY_STRING}  p=3164554
# the empty question mark discard the query string
RewriteRule  ^/showthread\.php    404.html?    [L,R=301]

或者您可以保持相同的网址,但显示404页面:

RewriteEngine On
RewriteCond %{QUERY_STRING}  p=3164554
RewriteRule  ^/showthread\.php      -          [L,R=404]

答案 1 :(得分:0)

尝试使用.这样的\字符来逃避这个问题。让我知道,它对你有用。

RedirectMatch 404 ^/showthread\.php?p=3164554$
相关问题