Skip to content

Instantly share code, notes, and snippets.

@seaders
Last active December 17, 2015 20:29
Show Gist options
  • Save seaders/5668016 to your computer and use it in GitHub Desktop.
Save seaders/5668016 to your computer and use it in GitHub Desktop.
Way to redirect a subdomain other than 'www' to a subdirectory with Apache. Apache mods enabled are 'headers', 'proxy', 'proxy_http' and 'rewrite'.
<VirtualHost *:80>
ServerName www.sixminute.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.sixminute\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*?)\.?sixminute\.com$
RewriteRule ^/(.*) http://www.sixminute.com/%1/$1 [P]
ProxyPassReverse / http://www.sixminute.com/%1/
SetEnvIf Origin "http(s)?://(www\.)?sixminute.com$" AccessControlAllowOrigin=$0sixminute.com
Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment