mod rewrite dynamic domains

Using a single web hosting account to host multiple sites

mod rewrite dynamic domains

Postby eddie_emmer » Tue Feb 10, 2009 2:39 am

allright, i'm searching for 2 days now, and i can't find the (right) answer :(

this is the situation:
I have mulitple domains, but i don't know the name of the domain.
all the domain's are pointing to the webroot.
for each domain i have a subfolder like this :

webroot/sites/domain1.com
webroot/sites/domain2.com
ect.

now i want a silent redirect from (www).domain1.com --> (www).domain1.com/sites/domain1.com

but remember, i don't know the domain name typed in the adress bar.
it should be dynamic... :)

hopefully someone can give me the right answer!

thx a lot!
eddie_emmer
 
Posts: 2
Joined: Tue Feb 10, 2009 2:33 am

Postby richardk » Tue Feb 10, 2009 3:51 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Fix missing trailing slashes.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/sites/%1%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

# Rewrite domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteRule ^(.*)$ /sites/%1/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby eddie_emmer » Tue Feb 10, 2009 3:56 am

You are absolute fantastic! this solved my problem completely!!
eddie_emmer
 
Posts: 2
Joined: Tue Feb 10, 2009 2:33 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 1 guest

cron