Using .htaccess to force either HTTP or HTTPS

Posted by ILMV on Stack Overflow See other posts from Stack Overflow or by ILMV
Published on 2010-03-30T15:31:57Z Indexed on 2010/03/30 15:33 UTC
Read the original article Hit count: 442

Filed under:
|
|

I have already got this code to force these URLs to HTTPS:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/my/?.*$                                          
RewriteCond %{REQUEST_URI} !^/my/basket/add/$          
RewriteCond %{REQUEST_URI} ^/login/?.*$
RewriteCond %{REQUEST_URI} ^/logout/?.*$
RewriteCond %{REQUEST_URI} ^/register/?.*$
RewriteCond %{REQUEST_URI} ^/newsletter/?.*$
RewriteCond %{REQUEST_URI} ^/reset-password/?.*$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And this works really well, but what I want to do is force any URL that does not comply with the above conditions to HTTP.

Any thoughts on how I could do this? It has to be done using .htaccess, I have been achieving it by using our PHP framework, but this has been messing our Google crawl.

Cheers!

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about http