【问题标题】:htaccess 301 Redirect with querystringhtaccess 301 使用查询字符串重定向
【发布时间】:2016-08-05 10:22:46
【问题描述】:

在我的 htaccess 中,我想对所有使用标准详细信息页面的产品进行 301 重定向

https://www.domain.com/standarddetail.asp​?cid=4135

到以下页面: https://www.domain.com/index.php?route=product/product&product_id=4135

我想对所有 (cid) 查询字符串执行此操作

我有几千个产品使用查询字符串 (cid) 出现在这个 standarddetail.asp 页面上,我希望它们使用 product_id= 查询字符串转到新页面。

我希望它们是 301 重定向。

这是怎么做到的?

【问题讨论】:

    标签: .htaccess redirect http-status-code-301


    【解决方案1】:

    在文档根目录的 htaccess 文件中,添加以下内容:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^cid=([0-9]+)
    RewriteRule ^standarddetail\.asp$ index.php?route=product/product&product_id=%1 [L,R=301]
    

    【讨论】:

    • 这不起作用。有一次,我尝试进行一对一的重定向,即使这样也没有用。这里一定有某种冲突。以下是之前失败的内容。重定向 301 /standarddetail.asp​?cid=4135 domain.com/index.php?route=product/product&product_id=4135
    • Jon Lin,你有什么建议吗?
    • @LeeFairbanks 抱歉,忘记了您无法匹配RedirectRedirectMatch 中的查询字符串。你需要使用 mod_rewrite
    • 那么重定向应该是什么?
    • 上面那个不行。 @Jon Lin code RewriteEngine On RewriteCond %{QUERY_STRING} ^cid=([0-9]+) RewriteRule ^standarddetail\.asp$ index.php?route=product/product&product_id=%1 [L,R=301] code
    猜你喜欢
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 2012-12-21
    • 2012-09-18
    • 2012-08-16
    相关资源
    最近更新 更多