简体   繁体   English

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

[英]Htaccess remove query string from 301 redirect

I write 301 redirect as below 我写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

but when I goes to 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/catalogue/novelty_linen_q_t/spongebob_squarepants/spongebob_squarepants_quilt_cover_wonderland/image/?size=275x275&helper=1281395930.79

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

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

Remove the query string from your Redirect directive, this is what you have: (make sure to scroll all the way to the right to see the comments) 从您的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

Not really sure why it's working at all, but you need to remove everything AFTER the ? 真的不知道为什么它的工作在所有,但你需要删除一切的? , leaving the ? 离开了? there. 那里。 That does have the unsightly side-effect of a stray question mark, but you can get rid of that using mod_rewrite, replacing the Redirect with: 那确实有一个迷路的问号的难看的副作用,但是您可以使用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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM