Skip to content

Instantly share code, notes, and snippets.

@ashucg
Created December 12, 2017 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashucg/5293b4524222f80f8270ee77eeef2933 to your computer and use it in GitHub Desktop.
Save ashucg/5293b4524222f80f8270ee77eeef2933 to your computer and use it in GitHub Desktop.
htaccess redirect non-www to www and HTTP to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment