Skip to content

Instantly share code, notes, and snippets.

@vkathirvel
Created December 16, 2015 15:02
Show Gist options
  • Save vkathirvel/f47030d1c0469a566e58 to your computer and use it in GitHub Desktop.
Save vkathirvel/f47030d1c0469a566e58 to your computer and use it in GitHub Desktop.
htaccess Non-WWW WWW Redirects
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^content\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^themes\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment