【问题标题】:Redirect question mark URL to the original URL将问号 URL 重定向到原始 URL
【发布时间】:2021-04-19 05:02:21
【问题描述】:

我想重定向以下网址

https://www.example.com/vmi10/? to https://www.example.com/vmi10/

这是一个 WordPress 网站。我怎样才能做到这一点?非常感谢您提供的任何帮助。

【问题讨论】:

  • 如果您有任何问题,请在您的问题中分享您的 htaccess 文件,谢谢。

标签: wordpress apache .htaccess mod-rewrite


【解决方案1】:

您可以将此重定向规则用作 main .htaccess 中的 topmost 规则:

RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+[^?]*\?\s
RewriteRule ^ %{REQUEST_URI}? [L,NE,R=301]

# other WP rules below this line

【讨论】:

    【解决方案2】:

    基本上,您想从我们在RewriteCond 条件模式中使用 ^$ 的 url 中删除空查询字符串,如下所示:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule (.*) /$1? [R=301,L]
    

    这将重定向https://www.example.com/vmi10/? to https://www.example.com/vmi10/

    这不会影响任何带有非空查询字符串的 url。

    在这里测试:https://htaccess.madewithlove.be?share=34570386-6b48-486b-ba84-32a222921502

    【讨论】:

    • 这将导致无限重定向
    猜你喜欢
    • 2011-01-18
    • 2012-04-15
    • 1970-01-01
    • 2019-12-11
    • 1970-01-01
    • 2012-08-07
    • 2014-10-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多