【问题标题】:how to htaccess 301 redirect pages with a question mark如何使用问号访问 301 重定向页面
【发布时间】:2014-07-08 21:15:06
【问题描述】:

我正在尝试 301 重定向我网站上不再存在的几个文件。我的网站以前在 Adob​​e Business Catalyst 上,但我把它放在没有 CMS 的普通服务器上,所以现在我留下了很多被 Google 索引的 asp 扩展。

我想将 http://www.example.com/FAQRetrieve.aspx?ID=51029 重定向到 http://www.example.com

我尝试使用此代码

Redirect 301 /FAQRetrieve.aspx?ID=51681 http://www.example.com/

但它不起作用。相反,当我转到该页面时,我会看到我的 404 错误页面。

我认为我需要以某种方式使用查询字符串,但我以前从未使用过它们,也找不到任何相关示例。谁能告诉我如何做到这一点?

【问题讨论】:

    标签: html regex apache .htaccess mod-rewrite


    【解决方案1】:

    您无法使用Redirect 指令匹配查询字符串。请改用 mod_rewrite 规则。将其保存在您的根 .htaccess 中:

    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} ^ID=51681$ [NC]
    RewriteRule ^FAQRetrieve\.aspx$ http://www.example.com/? [L,NC,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      • 2014-07-18
      • 2021-06-29
      • 1970-01-01
      • 1970-01-01
      • 2014-07-05
      • 2012-03-03
      相关资源
      最近更新 更多