Last active
October 5, 2016 21:02
-
-
Save niklasravnsborg/69af5553ce27d65b98f2 to your computer and use it in GitHub Desktop.
one.com uses subdirectories as subdomains, here is a handy rewrite
This file contains 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
RewriteEngine On | |
# redirect subdomains to matching folders | |
RewriteCond %{HTTPS} !=on | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteCond %{SERVER_ADDR} !=127.0.0.1 | |
RewriteCond %{SERVER_ADDR} !=::1 | |
RewriteCond %{HTTP_HOST} !.*\.yourhost.com | |
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# redirect all other traffic to main | |
RewriteCond %{HTTP_HOST} ^(?:www\.|)yourhost.com | |
RewriteCond %{REQUEST_URI} !^/main/? | |
RewriteRule ^(.*)$ /main/$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment