Steve Price Steve Price - 9 months ago 58
Apache Configuration Question

apache rewrite for certain urls to be http instead of https

Further to an earlier question I had where I needed to rewrite urls such as


I used this to fix it

RewriteCond %{QUERY_STRING} ^(.)(^|&)main_page=products_categories(.)$
RewriteRule ^(.*)$ /$1?%1%3 [R=301,L]

I've also discovered that I also have the same urls as https so


are giving me duplicate page penalties

Is it possible to modify my rewrite rule so that it also redirects to the http page at the same time as removing the


suffix so that

would become

Answer Source

Not sure why this question was unfairly down voted.

You can use this single rule to redirect both URLs to http://...:

RewriteEngine On

RewriteCond %{QUERY_STRING} (?:^|&)main_page=products_categories(?:&|$) [NC]
RewriteCond %{QUERY_STRING} (?:^|&)(cPath=[^&]+) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI}?%1 [R=301,L,NE]