Correct way to redirect HTTP to HTTPS


I’d like to set my domains up so that HTTP:// auto redirects to HTTPS:// What’s the correct way to do that in the Dreamhost system?


It might vary some depending on your application and needs but you will probably want to do it with .htaccess

If it’s Wordpress you can simply change your site URLs.


it takes a bit of code in your domains htaccess file. There is more than one answer here, you can google other code snips, but I use:

RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://EXAMPLE.COM/$1 [R=permanent]

literally: if the server_port is NOT 443 then redirect to https and preserve url extensions ($1).


Thank you!

  • Generic Steps to Switch from HTTP to HTTPS -

• Read all info at your host concerning certificates & switching to HTTPS and when applicable, follow those instructions.

• Install security certificate.

• Have your host enable HTTPS (if needed.) This will enable access from both HTTP & HTTPS allowing normal access while you test.

• Go through site, page by page & make sure all file paths are relative (no protocol.) Test by accessing site using HTTPS and look for any browser alerts.

• Install 301 code in .htaccess fileRewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301][size=1]Note: your server may require a different code[/size]

• Go through site again, page by page, and test. Any remote absolute links will need to be HTTPS including those found in scripts & pluggins. If you publish Adsence or other advertising, links in these scripts need to be HTTPS also (or just remove the protocol altogether.)

• Update sitemap.xml (if applicable) and submit to appropriate agencies (Google, Bing, Yandex, etc)

• In Google Search Council create a new site using HTTPS (do not use the Change of Address form.) It will take a few days to start populating information. This is normal & traffic to old site (HTTP) will drop off accordingly.

• Bing Webmaster Tools, Yandex & others should update automatically once they crawl your new pages. Updating/re-submitting sitemap.xml should speed up this process.