Multiple Domain Subdirectory Issue

Using a single web hosting account to host multiple sites

Multiple Domain Subdirectory Issue

Postby theocode » Mon Feb 12, 2007 10:27 am

I've got a problem, that I am unable to figure out the solution. I have multiple domains forwarded to one host. They are all then directed to their correct subdirectory depending on where they are coming from. My problem arises when someone tries to go to a subdirectory of that domain.

www.companyname.com/dir1 instead of www.companyname.com/dir1/

If they forget the final slash on the directory, they are then not forwarded anywhere, and send to the main root directory of my hosting account. With the uri in the address bar being all wonky. Something like

www.companyname.com/domains/www.companyname/dir1/

Here is my setup...

Code: Select all
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{SERVER_NAME} ^(www\.)?companyname\.net$ [NC]
RewriteRule ^ - [E=SITE_ADMIN:admin@companyname.net,E=SITE_NAME:www.companyname.net,E=SITE_ROOT:domains/www.companyname]

RewriteCond %{SERVER_NAME} \.?^((server1\.|server4\.|playground\.)companyname)\.net$\.?(:80)?$ [NC]
RewriteRule ^ - [E=SITE_ADMIN:admin@companyname.net,E=SITE_NAME:%1.net,E=SITE_ROOT:domains/%1]

RewriteCond %{SERVER_NAME} ^(www\.)?othercompanyname\.com$ [NC]
RewriteRule ^ - [E=SITE_ADMIN:admin@othercompanyname.com,E=SITE_NAME:www.othercompanyname.com,E=SITE_ROOT:domains/www.othercompanyname]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule !^domains %{ENV:SITE_ROOT}%{REQUEST_URI} [QSA,L]


I have a feeling the fix wouldn't be too hard, I am just missing something. If anyone could point me in the right direction I would be most appreciative.
theocode
 
Posts: 5
Joined: Mon Feb 12, 2007 10:15 am

Postby richardk » Tue Feb 13, 2007 11:15 am

Add
Code: Select all
RewriteCond %{DOCUMENT_ROOT}/%{ENV:SITE_ROOT}%{REQUEST_URI} -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

before
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule !^domains %{ENV:SITE_ROOT}%{REQUEST_URI} [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Thanks

Postby theocode » Tue Feb 13, 2007 11:28 am

That worked perfectly, thanks a bunch richardk.

I was totally going the wrong direction when I was looking for a remedy. Its nice that there is a place to go when I am lost.
theocode
 
Posts: 5
Joined: Mon Feb 12, 2007 10:15 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 27 guests

cron