rewrite engine - sub domains / directories

AlaskanWolf

Well-Known Member
Aug 11, 2001
537
0
316
Fremont CA
Im trying to get this to work

http://domain.com/members/USER

to become

http://USER.domain.com

i got the code below but it doesnt work, i also added a wild card to dns. All i get is the apache page.

The only way we got this to work is with http://www.domain.com, in that case it does forward to /home/user-directory/www/members/www

Anyone got any ideas??

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.|^([a-z0-9-]+)\.userdomain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([a-z0-9-]+)\.userdomain\.com/(.*) /home/user/public_html/members/$1/$2
RewriteRule ^www\.([a-z0-9-]+)\.usterdomain\.com/(.*) /home/user/public_html/members/$1/$2
 

AlaskanWolf

Well-Known Member
Aug 11, 2001
537
0
316
Fremont CA
this is how pathedic us admins are....laying in bed last night ready to doze off, i said to myself & what if i have to add a ServerAlias tag to it&

sure enought...works great now

heres the code for everyone to enjoy


&VirtualHost ip-add&
ServerAdmin [email protected]
DocumentRoot /home/dsshost/public_html
BytesLog domlogs/youruserdomain.com-bytes_log
ServerName www.youruserdomain.com
ServerAlias youruserdomain.com www.youruserdomain.com *.youruserdomain.com
CustomLog domlogs/youruserdomain.com combined
ScriptAlias /cgi-bin/ /home/dsshost/public_html/cgi-bin/


RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.youruserdomain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.youruserdomain\.com(.*) /directory/$1$2

&/VirtualHost&