Htaccess从301重定向中删除查询字符串

时间:2012-08-21 12:43:19

标签: .htaccess magento

我写了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

1 个答案:

答案 0 :(得分:1)

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

#                                                                                                                           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

不确定为什么它会起作用,但你需要删除所有 AFTER ?,然后将?移到那里。这确实有一个流浪问号的难看的副作用,但你可以使用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]