.htaccess - 301 Redirect without Query String (Wordpress) -
i switched client's website concrete5 wordpress , have bunch of links on google , other sites 404. trying redirect many of links possibly can.
we put many of them in our .htaccess file such
redirect 301 /news-articles/community/?cat=6 http://our-site.ca/news-articles/community/ redirect 301 /news-articles/community/2015-in-the-community/?cat=1 http://our-site.ca/news-articles/community/2015-in-the-community/ redirect 301 /news-articles/accident-benefits-update/?cat=5 http://our-site.ca/news-articles/accident-benefits-update/
we noticed if have query string @ end of old url's , tried google around solution found has 1 kind of url being redirected. , have hundreds.
edit: if keep ?cat=5 or whatever query string is, breaks wordpress , goes our 404 page.
you can't match query string in redirect
directive. try using mod_rewrite instead, can match query string %{query_string}
variable:
rewriteengine on rewritecond %{query_string} ^cat=6$ rewriterule ^news-articles/community/$ http://our-site.ca/news-articles/community/? [l,r=301] rewritecond %{query_string} ^cat=1$ rewriterule ^news-articles/community/2015-in-the-community/$ http://our-site.ca/news-articles/community/2015-in-the-community/? [l,r=301] rewritecond %{query_string} ^cat=5$ rewriterule ^news-articles/accident-benefits-update/$ http://our-site.ca/news-articles/accident-benefits-update/? [l,r=301]
make sure remove leading slash of regex pattern in rule.
Comments
Post a Comment