skip to Main Content
Menu

Set up your site to accept both http and https

We just got our SSL for the site as we were looking at attracting more clients, well for facebook and some other projects that required SSL.

Anyway our dilemma was that if left alone, the site’s http and https are both accessible even with the search engines.. currently our site has a ranking of 2 with google.. and if we did not take care of this.. google would and could treat https content as duplicate content.. this does not sit highly with search engines.

So after some soul searching we realized we needed to 1) make http as priority 2) use https only for projects.. with this in mind we had to alter our .htaccess slightly (please refer to green text)..

# force https for all URLs in /checkout
RewriteCond %{HTTPS} =off
RewriteRule ^checkout https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# do not do anything for already existing files
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ – [L]

# force http for all other URLs that are not in /checkout
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/checkout
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# your other rules here, e.g.:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

We created a folder (which we did not name here for obvious reasons, just refer to checkout).. and i guess the above is self-explanatory..

htaccess adapted from : http://stackoverflow.com/questions/7133599/redirect-http-to-https-for-one-page

 

Alphonse

Editorial Staff at ETN Multimedia is led by Alphonse Tan. Page maintained by Alphonse Tan

Back To Top