【问题标题】:Htaccess remove query string from 301 redirectHtaccess 从 301 重定向中删除查询字符串
【发布时间】:2012-08-16 19:30:33
【问题描述】:

我写301重定向如下

Redirect 301 /catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79 http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

但是当我去 http://www.thebedroom.com.au/catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79

它重定向 http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

....... 我需要重定向 http://www.thebedroom.com.au/manchester/character-bedding.html

【问题讨论】:

  • 从重定向中移除查询字符串?
  • 是的,我使用 301 重定向到新的 url,但它使用查询字符串重定向,所以我需要删除该查询字符串

标签: .htaccess magento


【解决方案1】:

从您的重定向指令中删除查询字符串,这就是您所拥有的:(确保一直滚动到右侧以查看 cmets)

#                                                                                                                           This question mark right here is why you have a query string in your redirect ---------v
Redirect 301 /catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79 http://www.thebedroom.com.au/manchester/character-bedding.html?size=275x275&helper=1281395930.79

完全不确定它为什么会起作用,但是您需要在?之后删除所有内容,将? 留在那里。这确实有一个杂散问号的难看的副作用,但你可以使用 mod_rewrite 摆脱它,将 Redirect 替换为:

RewriteEngine On
RewriteRule ^catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?$ /manchester/character-bedding.html? [L,R=301]

【讨论】:

    猜你喜欢
    • 2014-11-11
    • 1970-01-01
    • 2014-02-02
    • 2013-06-21
    • 2012-05-29
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    相关资源
    最近更新 更多