.htaccess redirect https to http not working

Posted by Ira Rainey on Stack Overflow See other posts from Stack Overflow or by Ira Rainey
Published on 2010-06-05T12:29:35Z Indexed on 2010/06/05 12:32 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

I am trying to catch any https traffic to the front of my site so:

https://www.domain.com

is redirected to:

http://www.domain.com

However other subdomains need to be redirected elsewhere. For the most part this is all working, apart from the https -> http redirection. Here's my .htaccess file at the moment:

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

RewriteCond "%{HTTP_HOST}" !^www.* [NC]
RewriteCond "%{HTTP_HOST}" ^([^\.]+).*$
RewriteRule ^(.*)$ https://secure.domain.com/a/login/%1 [L,R=301]

It would seem that this bit:

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

isn't working as I would imagine. In fact it doesn't seem to redirect at all.

In another subdirectory I have the opposite in effect which works fine:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

so my thinking is the opposite should have done the job, but seemingly not.

Any thoughts anyone?

© Stack Overflow or respective owner

Related posts about apache

Related posts about .htaccess