user.domain.com/f1/f2/ -> www.domain.com/user/f1/f2/

Using a single web hosting account to host multiple sites

user.domain.com/f1/f2/ -> www.domain.com/user/f1/f2/

Postby dannood » Thu Feb 08, 2007 11:33 am

Hi, I know this is simple..but I cant figure out. please help this noob.

http://user.domain.com/folder1/folder2

to

http://www.domain.com/user/folder1/folder2
dannood
 
Posts: 1
Joined: Thu Feb 08, 2007 5:04 am

Postby richardk » Fri Feb 09, 2007 3:49 pm

You need DNS for the sub domains.
The sub domains need to point to the directory on the server where the .htaccess file is (/).

Then in the .htaccess file:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain\.com$ [NC]
RewriteRule ^(.*)$ /%2/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 23 guests

cron