Skip to content

Instantly share code, notes, and snippets.

@VIVEKLUCKY249
Forked from vkathirvel/.htaccess
Created January 28, 2017 06:36
Show Gist options
  • Save VIVEKLUCKY249/5958a447cd48b3d6ab8a7a083e9b8ba1 to your computer and use it in GitHub Desktop.
Save VIVEKLUCKY249/5958a447cd48b3d6ab8a7a083e9b8ba1 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