Author Topic: How to migrate htaccess to SSL website  (Read 264 times)

Offline certforumz

  • Cert Exams
  • Administrator
  • Hero Member
  • *****
  • Posts: 826
  • Ask me a question ...
    • CertExams - CCNA, A+, Network+, and Others
How to migrate htaccess to SSL website
« on: July 10, 2017, 03:46:51 AM »
Redirect everything to HTTPS

There is hardly any reason not to run your website over SSL (HTTPS). Also it is very important that you answer to both HTTP and HTTPS. This snippet redirects all non-HTTPS traffic to HTTPS:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{HTTPS} !on [NC]
 RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

It is important to choose one true (canonical) URL for SEO reasons.

Source:
https://www.leaseweb.com/labs/2015/10/rewritecond-and-rewriterule-tricks-for-htaccess/