【问题标题】:Make dynamic links (with ?) return error 404 not found制作动态链接(带?)返回错误 404 not found
【发布时间】:2015-09-01 02:18:34
【问题描述】:

使用 .htaccess(还有其他解决方案吗?)有没有办法让站点的所有动态链接(包含符号的链接?)返回 404 not found 响应标头?

例如:

http://www.example.com/?bla_bla - 将返回 404

http://www.example.com/test/index.html?no_redirect=true - 将返回 404

【问题讨论】:

标签: apache .htaccess dynamic hyperlink http-status-code-404


【解决方案1】:

我假设您要求任何包含查询字符串的请求返回 404。如果 您想要的,请使用以下内容:

RewriteEngine On
RewriteCond %{QUERY_STRING} .+
RewriteRule .* - [R=404,L]

这将使用正则表达式.+ 来检查查询字符串中是否有一个或多个字符。如果满足该条件,任何路径(.* 匹配 0 个或多个字符)都将被重定向为 404

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-16
    • 2019-12-09
    • 2018-12-16
    • 1970-01-01
    • 2015-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多