View Single Post
Old 11-18-2007, 10:55 AM  
dissipate
The Dirty Frenchman
 
dissipate's Avatar
 
Industry Role:
Join Date: Nov 2005
Location: Lost Angeles
Posts: 8,904
Quote:
Originally Posted by Fris View Post
if you want to create sub domains on the fly try something like this

Options +FollowSymLinks

RewriteEngine On

# mod_dir fix
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+)\.domain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ http://%2.domain.com%{REQUEST_URI}/ [R=301,L]

# strip sub subdomains
RewriteCond %{HTTP_HOST} ^.*\.([^\.]+\.domain\.com)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# abc.domain.com --> /subs/abc
RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteCond %1:::%{REQUEST_URI} !^(.+):::/subs/\1(/.*)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%1/ -d
RewriteRule ^(.*)$ /subs/%1/$1 [QSA,L]

Still, wont work without a wildcard DNS record to point the subdomains to the documentroot of the TLD
dissipate is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote