https to http using htaccess

By in Tutorials, Web, Web Space on April 16, 2010

htaccess directives can be used to redirect a website from http to https using mod_rewrite.
But as we all know the https protocol involves encryption and decryption at both the server and the client end, this makes the site very slow.
One thing we can do is redirect to https only for the pages which sends or recieves confidential information over the connection,but again, browsers don’t allow any components of “http://” in the page which is being rendered in https protocol and show an untrusted icon of a lock with a message that “the page contains both insecured and secured items”.
Mozilla shows it as “connection partially encrypted”
For this we need to change all the links on the secured page to https url, but we dont want the other pages to load as https.
So we write an htaccess to rewrite https url to http url for the pages we dont want to load as https.
Here is the sample code:

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !/securedPage.php$
RewriteRule ^(.*)$ http://www.example.com/$1

Tags: , , , , , ,

Leave a Reply