Showing posts with label www. Show all posts
Showing posts with label www. Show all posts

Monday, September 9, 2013

Redirect your site to https and www using htaccess

<ifmodule mod_rewrite.c>
   RewriteEngine on

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

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

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

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</ifmodule>