back to top
shopping basket

View your basket

Photobooks from PiciScan

What our customers are saying:

The service has been friendly, efficient, careful and very good value for money.

Read more...

How to force re-direct a browser to https using htaccess

How to force re-direct a browser to https using htaccess

PiciScan Web Design Blog RSS Feed

Posted on: Thursday, 12 February 2015

So you've bought a shiny new SSL certificate for your website and you've gone through all the instructions from the host provider and the certificate vendor and you type in your URL, expecting to see your lovely address with a padlock beside it in the address bar, and ... nothing.

My first thought when that happened to us was, "What a bloomin' waste of money!" But, a quick search of the internet and I found out how to fix the problem with a minor adjustment to the .htaccess file for the website.

There are great number of things that the .htaccess file is able to help you with, some of which I plan to cover in this blog, but in this case you want to force the browser to redirect users to the secure version of your site. Below I go through step-by-step instructions on the creation of an .htaccess file and include the code you will need for this task. If you already know how to create the .htaccess file, then just skip these steps.

1. Open Notepad or a different text-editor on your computer.

2. Copy and paste this code into the text-editor:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L]

3. Change "mydomain.com" for whatever version of your domain name you registered with the certificate vendor. So, if you registered your address with www. then use it, otherwise, do not.

4. In Notepad, you would then click: File > Save As... and click in the box "Save as type", changing this to "All files".

5. In the "File Name" box, type ".htaccess" (without the quotation marks), and click "Save".

All that's left for you to do now is upload the .htaccess file you've just created to the route folder for your website on your server - in our case its httpdocs - and re-visit your website in a browser. You should now see a padlock beside the address.

Job done!

Mark founded PiciScan in 2010, and sold it in October 2015 to Web By Numbers Ltd, who now employ him! He likes Star Wars, playing escape games and looking after his bonsai tree.

comments powered by Disqus

The Latest From our Scanning Blog

Christmas 2015

Christmas 2015

Posted: 14 December 2015

It’s nearly the time of year to be going up into the loft and bringing down all the Christmas decorations, locating the tree and seeing if those lights from last year still work, or if you need to buy any more...

Read more

The Latest From our Web Design Blog

Box Sizing: Border-Box

Box Sizing: Border-Box

Posted: 24 March 2016

I first came across box-sizing: border-box when it cropped up in a temporary colleague's CSS. I found it pretty annoying when I picked up work that he'd started as it seemed to get in the way. This was because, as I said in a previous post on margin ...

Read more