简体   繁体   中英

301 redirect .HTACCESS - Remove Query String

I have a 404 page being found by analytics. I'm having trouble figuring out the correct syntax for redirecting the link below via .htaccess. Can anyone offer a solution? Thank you very much.

http://www.mywebsite.com/product-categories?format=feed&type=atom

I tried this and plenty of others without success.

RewriteCond %{QUERY_STRING} ^format=feed&type=atom$
RewriteRule ^product-categories/$ http://www.mywebsite.com/product-categories/?  [L,R=301]

You have condition reverse in your RewriteRule . Use this rule:

RewriteCond %{QUERY_STRING} ^format=feed&type=atom$ [NC]
RewriteRule ^product-categories/?$ /product-categories/? [NC,NE,L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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