Search code examples
mod-rewritemagentourl-rewritingapache-configmagento-1.4

magento https/http redirection


Is there a way to redirect domains based on its parameters in magento.

Eg:

if user trying to load https://stage.domain.com/ the system should redirect it to http://stage.domain.com/,

if user trying to load https://stage.domain.com/all_access_profile the system should redirect it to http://stage.domain.com/all_access_profile ,

But the rest can goto its actual link what user actually requested.

I have got this one from @stackoverflow

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This one is always redirecting. How this needs to be changed to get url parameters based redirection.

Thanks


Solution

  • You want to redirect from the secure (https) to the insecure (http) but the rewrite rule http%1 is directing to the secure. That is the wrong way round so it should be:

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTPS} ^on
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]