main domain forwarding to a directory

Using a single web hosting account to host multiple sites

main domain forwarding to a directory

Postby stillife » Tue Jan 02, 2007 11:07 pm

Hi all,

I'm having a bit of problem achieving this scheme:

I have two domains: domainA.com and domainB.com
1) I want to point domainA.com to a folder called /Myfolder/ (/ is the DocumentRoot)
2) I want to point domainB.com to a folder called /Yourfolder/
I also want to have a couple of subdomains:
1) tools.domainA.com to go to folder /tools/
2) projects.domainA.com to go to folder /Myfolder/projects/

I've got the following in my .htaccess but I'm having some problems:

RewriteCond %{HTTP_HOST} ^(www.)?domainA.com$
RewriteCond %{REQUEST_URI} !^/Myfolder/
RewriteRule ^(.*)$ /Myfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?tools.domainA.com$
RewriteCond %{REQUEST_URI} !^/tools/
RewriteRule ^(.*)$ /tools/$1
RewriteCond %{HTTP_HOST} ^(www.)?projects.domainA.com$
RewriteCond %{REQUEST_URI} !^/Myfolder/projects(/.*)?$
RewriteRule ^(.*)$ /Myfolder/projects/$1
RewriteCond %{HTTP_HOST} ^(www.)?domainB.com$
RewriteCond %{REQUEST_URI} !^/Yourfolder/
RewriteRule ^(.*)$ /Yourfolder/$1

when I type in any addresses of type projects.domainA.com or click on links within pages accessed through that subdomain, I get the whole path in address bar:
eg. projects.domainA.com/test2/test.php becomes projects.domainA.com/Myfolder/projects/test2/test.php

Can anyone tell me what I'm doing wrong and if there is a better way of managing these things.

Thanks in advance for any advice,

Still
stillife
 
Posts: 1
Joined: Tue Jan 02, 2007 10:57 pm

Postby richardk » Wed Jan 03, 2007 9:19 am

This should work fine. You shouldn't have got a redirect and if you still do it may be a problem with your server configuration or in your script.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domainA\.com$ [NC]
RewriteRule !^Myfolder(/.*)?$ /Myfolder%{REQUEST_URI} [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?tools\.domainA\.com$ [NC]
RewriteRule !^tools(/.*)?$ /tools%{REQUEST_URI} [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?projects\.domainA\.com$ [NC]
RewriteRule !^Myfolder/projects(/.*)?$ /Myfolder/projects%{REQUEST_URI} [QSA,L]

RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.com$ [NC]
RewriteRule !^Yourfolder(/.*)?$ /Yourfolder%{REQUEST_URI} [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 14 guests

cron