【问题标题】:Redirect 301 in link在链接中重定向 301
【发布时间】:2014-05-09 12:55:58
【问题描述】:

我想为地址设置重定向 301:

http://example.com/?test=123sdf

到:

http://example.com/

我该怎么做?我试试:

Redirect 301 /?test=123sdf http://example.com/

但这不起作用。我想在我的 .htaccess 文件中添加这个。

【问题讨论】:

    标签: php apache .htaccess redirect web


    【解决方案1】:

    RewriteRule 仅将 REQUEST_URI 与查询字符串匹配。您将需要 RewriteCond 来匹配查询。将此代码放入您的 DOCUMENT_ROOT/.htaccess 文件中:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^test=123sdf$ [NC]
    RewriteRule ^$ /? [L,R=301]
    

    【讨论】:

    • 奇怪,现在不行了。感谢您的回答
    【解决方案2】:

    你可以使用;

    RewriteEngine on
    RewriteRule ^test=123sdf$ / [R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 1970-01-01
      • 1970-01-01
      • 2018-07-23
      • 2016-02-11
      • 1970-01-01
      相关资源
      最近更新 更多