Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jjulian/284856 to your computer and use it in GitHub Desktop.
Save jjulian/284856 to your computer and use it in GitHub Desktop.
# To rewrite server subdomains into directories: Capture the subdomains
# in a rewrite condition, then use backreferences to them in the rule.
# . run apache locally
# . add project.client.staging.domain.com to /etc/hosts
# . curl project.client.staging.domain.com
# . in rewrite_log, you'll see rewrite '/' -> '/root/staging/client/project'
RewriteLogLevel 3
RewriteLog "rewrite_log"
RewriteEngine On
ServerName project.client.staging.domain.com
RewriteCond %{SERVER_NAME} ^(.*?)\.(.*?)\.(.*?)\.
RewriteRule ^.*$ /root/%3/%2/%1 [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment