【问题标题】:htaccess 301 redirect - Remove query stringhtaccess 301 重定向 - 删除查询字符串
【发布时间】:2016-04-14 09:28:27
【问题描述】:

我想将具有查询字符串的网址重定向到这样的首页

来自

https://cococo.com?abc=123

https://cococo.com

因为当我输入 https://cococo.com?abc=123 时,它也会显示首页,所以我认为它对 seo 不友好。

如何编写 .htaccess 来解决这个问题?

下面那个是错的。

RewriteCond %{QUERY_STRING} .+
RewriteRule ^\?(.*)$ %{ENV:REWRITEBASE}?$1 [L,R=301]

【问题讨论】:

    标签: php apache .htaccess redirect mod-rewrite


    【解决方案1】:

    您可以使用此规则仅在登录页面上删除查询字符串:

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

    【讨论】:

      猜你喜欢
      • 2014-02-02
      • 2012-08-16
      • 2014-11-11
      • 1970-01-01
      • 1970-01-01
      • 2013-06-21
      • 2014-06-01
      • 2017-04-13
      相关资源
      最近更新 更多