【问题标题】:How to redirect dynamic urls to their relevant static urls in htaccess?如何将动态 url 重定向到 htaccess 中的相关静态 url?
【发布时间】:2016-05-25 23:26:20
【问题描述】:

动态网址就像

example.com/wp/?2323e=467467
example.com/any-page.html?2323e=567856
example.com/any-folder/other-page.html?2323e=6435346

我想将它们全部重定向到它们的静态网址,例如

example.com/wp/
example.com/any-page.html
example.com/any-folder/other-page.html

请建议如何使用 301 重定向来做到这一点

【问题讨论】:

  • 您不需要重定向。现在已经调用了目标页面
  • 但在网站管理员中,它们被列在软 404 错误中
  • example.com/any-page.html?2323e=567856example.com/any-page.html 相同,查询字符串为 ?2323e=567856
  • 是的,我明白这一点。但是如何处理因此而发生的soft404。

标签: php .htaccess redirect mod-rewrite url-redirection


【解决方案1】:

要删除查询字符串,您可以使用:

RewriteEngine on


RewriteCond %{QUERY_STRING} .+ [NC]
RewriteRule ^ %{REQUEST_URI}? [L,R]

这将重定向:

/foo?querystring

/foo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-15
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多