Created
March 17, 2017 11:30
-
-
Save fernandiez/bdceedb2f609639871859848fff2966c to your computer and use it in GitHub Desktop.
Redirect domain to https, subdomain to https and non-www to www
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect domain to https, subdomain to https and non-www to www | |
# http://stackoverflow.com/questions/37614937/htaccess-redirect-domain-to-https-subdomain-to-https-and-non-www-to-www | |
RewriteEngine on | |
# redirect no-www to www only main domain, not with subdomain | |
RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC] | |
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L] | |
# redirect http to https all domain | |
RewriteCond %{HTTPS} off | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment