htaccess (https to http) htaccess (https to http) codeigniter codeigniter

htaccess (https to http)


You could put your static contents on a different domain like static.example.com and disable the HTTPS to HTTP redirect for such requests.

Use //static.example.com/… to reference that resources to use the same URI scheme as the document the reference is contained in and test in your RewriteRule if such a resource is requested:

RewriteCond %{HTTPS} onRewriteCond %{HTTP_HOST} !=static.example.comRewriteRule !(^|/)(abc|xyz|pqr) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]


Okay . I think I found the solution . i tested it too on my server . works fine .. needed a http referer condition too in the rewrite

RewriteCond %{HTTPS} !onRewriteRule ^(.*)/(abc|xyz|pqr)(.*)$ https://%{HTTP_HOST}/cart/$2$3 [R=301,NC,L]RewriteCond %{HTTPS} onRewriteCond %{HTTP_REFERER} !^https(.*)/(abc|xyz|pqr)(.*)$ [NC]RewriteCond %{REQUEST_URI} !^(.*)/(abc|xyz|pqr)(.*)$ [NC]RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]

Now if you visit any of the pages with (abc,xyz,pqr) it will be redirected to https://...also all the embedded link will be served from https . so the browser wont show the partial encryption warning (red warning sign at the status bar)

when you move away from the any of these page, that page will be on ssl because of referer check, and this page might show partially encrypted warning (but i can live with it). Once you move away from this page everything will be non-ssl.

Hope this helps someone !!!