Skip to content

Instantly share code, notes, and snippets.

@faizanayubi
Created October 11, 2015 07:49
Show Gist options
  • Save faizanayubi/108094e3a86e2b05e040 to your computer and use it in GitHub Desktop.
Save faizanayubi/108094e3a86e2b05e040 to your computer and use it in GitHub Desktop.
putting this in your .htaccess file will add subdomain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com
RewriteRule ^(.*)$ http://domain.com/subdomains/sub/$1 [L,NC,QSA]
For a more general rule (that works with any subdomain, not just sub) replace the last two lines with this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
RewriteRule ^(.*)$ http://domain.com/subdomains/%1/$1 [L,NC,QSA]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment