Using .htaccess To Redirect HTTPS To HTTP
To redirect from HTTPS to HTTP on the home page only using the following rule.
RewriteCond %{HTTPS} on
RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301,L]
The variable %{HTTPS} will be either "on" or "off" and will be enabled even if SSL is not installed on your site. The rule above sees that HTTPS is on and redirects the home page to the HTTP version. You can even chain lots of rules together like this.
RewriteCond %{HTTPS} on
RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301]
RewriteRule ^inner/directory/?$ http://%{SERVER_NAME}/inner/directory/ [R=301,L]
Note that you should end your last rule with L so that no other rules on the page are run. Also, you need to make absolutely sure that you are not redirecting any pages that are integral to the security of your shopping cart as this will turn off HTTPS for those pages.
You can also do the same thing using the ${SERVER_PORT} variable.
RewriteCond %{SERVER_PORT} 443
RewriteRule ^/?$ http://%{SERVER_NAME}/ [R=301,L]
The port for HTTPS is 443 so if the port being communicated through is 443 we need to redirect.
Comments
help needed to move from https to http
hi there,
I am trying to redirect https to http for the website coupon aid
I changed htaccess but it doesn't seem to work. Could you take a look and see what the problem is?
it's not redirecting :(
If it isn't redirecting then
If it isn't redirecting then there are a couple of things you can try. The rules above require mod_rewrite being available on your Apache server, if it isn't on then the rules throw and error. There may be an issue with the expression you are using to redirect if you are trying to do it with an inner directory. Either way, any errors should be logged by your Apache server in the error.log so if nothing works that should point you in the right direction.
Post new comment