Thursday, September 20, 2012

htaccess non-www and www http to https


RewriteEngine on

RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

<Files .htaccess>
order allow,deny
deny from all
</Files>

No comments:

Post a Comment