Forcing SSL and WWW in .htaccess

Knowledge base article id: 49

Use the following code in the htaccess file for making sure that all pages served up are www and SSL.

Replace example.com with the domain.

######################################
# force ssl and www
######################################
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
  • www, ssl, force ssl
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Solving the ERR_BLOCKED_BY_XSS_AUDITOR in Chrome

You are reading this article because you have saved something in wordpress and received an error...

additional security/performance settings for .htaccess

Below is some additional rules for your htaccess file which provides some performance and...

301 redirect all traffic from domain A to the root of domain B

If you need to 301 redirect all the traffic from olddomain.com to the index page of newdomain.com...