Redirect HTTP to HTTPS

Since Google announced that they were going to start using HTTPS as part of their ranking you would of seen a vast amount of websites switching to use HTTPS instead of using HTTP. If you are switching your site to use HTTPS you need to remember that all your pages that are indexed into Google or websites that are linking to your site will still be pointing to your old HTTP page. Therefore you need to make sure that you redirect all non-HTTPS pages to HTTPS.

Redirect With htaccess

If you are using an apache server then you can use the following code snippet and enter it into your htaccess file. This will search for anything coming in on port 80 which is the default for HTTP and will redirect it to HTTPS.

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

Redirect On Nginx

If you are using an Nginx then you can add the following into your server conf. This will listen to requests on port 80 and redirect to your server with a HTTPS prefix, all you have to do is replace the example.com with your own domain.

server {
    listen      80;
    server_name example.com;
    return 301   https://$server_name$request_uri;
}
Written on

UpChecker

Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring