Redirect domain.com/* to *.domain.com

Using a single web hosting account to host multiple sites

Redirect domain.com/* to *.domain.com

Postby federico15 » Wed Feb 07, 2007 8:30 am

hello
How can i redirect

domain/anything to anything.domain.com
And make an exception for the images folder

Thanks
federico15
 
Posts: 4
Joined: Thu Feb 01, 2007 12:58 pm

Postby richardk » Thu Feb 08, 2007 10:36 am

And make an exception for the images folder

Because of relative paths? The problem is not that mod_rewrite rewrites it, it's that the browser sees the wrong URL.

You need DNS for the sub domains.
The sub domains need to all point to the directory that contains the .htaccess file.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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 95 guests

cron