htaccess – Redirect HTTPS to HTTP Except Specific Pages

.htaccessredirect

I want to redirect https to http for almost all pages, except for checkout, cart and account. Especially to improve speed.

How do I define that inside my htaccess?

All my rewrite rules in htaccess:

RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/customer/account/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteCond %{REQUEST_URI} !^/wishlist/
RewriteCond %{REQUEST_URI} !^/ebizautoresponder/
RewriteCond %{REQUEST_URI} !^/admin/dashboard/index/key/
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

##### Block unwanted Crawler Bots that clog your server #####

RewriteCond %{HTTP_USER_AGENT} MJ12bot
RewriteRule .* - [F]
RewriteCond %{HTTP_USER_AGENT} 80legs [NC]
RewriteRule ^ - [F]

############################################
## workaround for HTTP authorization
## in CGI environment

    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]

############################################
## always send 404 on missing files in these folders

    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

    RewriteRule .* index.php [L]

I use these settings for secure and unsecure:

enter image description here

Best Answer

What you have so for should work pretty well. The actuall redirect part I've added below

RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/customer/account/
RewriteCond %{REQUEST_URI} !^/checkout/
RewriteCond %{REQUEST_URI} !^/wishlist/
RewriteCond %{REQUEST_URI} !^/ebizautoresponder/
RewriteCond %{REQUEST_URI} !^/admin/dashboard/index/key/
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Related Topic