【问题标题】:How to use .htaccess to remove ?fontstyle=f-smaller at the end of an URL?如何使用 .htaccess 删除 URL 末尾的 ?fontstyle=f-smaller?
【发布时间】:2012-07-11 02:54:19
【问题描述】:

我使用的模板在 URL 的末尾生成带有 ?fontstyle=f-smaller 或 ?fontstyle=f-smaller 的链接(根据用户的文本大小偏好)。现在这导致了明显的重复内容问题。我已禁用该功能,但仍在提供 URL。

我想使用 .htaccess 将这些内容从我的 URL 中剥离。例如: http://www.mysite.com/article?fontstyle=f-smaller 将重定向到 http://www.mysite.com/article

我已经在这里和其他地方搜索过它,但我只找到了如何删除片段。我想要的更改是一个片段中,我不知道该怎么做。

提前致谢

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    试试

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^(.*)(^|&)fontstyle=f-smaller(.*)$
    RewriteRule ^(.*)$ /$1?%1%3 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2016-09-11
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-13
      相关资源
      最近更新 更多