Skip to content

Instantly share code, notes, and snippets.

View bmsterling's full-sized avatar

Benjamin Sterling bmsterling

View GitHub Profile
@bmsterling
bmsterling / Subdomins on the fly
Created April 17, 2011 02:46
Allows you to create subdomains on the fly w/out you having to create them in your cpanel
RewriteEngine On
RewriteBase /
# redirects subX.subY.domain.com to /-client/subY/subX
RewriteCond %{REQUEST_URI} !^/-
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.([^\.]+)
RewriteCond %{DOCUMENT_ROOT}/-clients/%3/%2 -d
RewriteRule ^(.*)$ -clients/%3/%2/$1 [L]
# redirects subY.domain.com to /-client/subY/