Multiple domains with one virtual host

Using a single web hosting account to host multiple sites

Multiple domains with one virtual host

Postby Menta2K » Thu Mar 15, 2007 4:35 am

Ok there is the case
one virtual host domain1.com
with domain aliases domain2.com
document root for that virtual host is /var/www/html
inside /var/www/html i make folder domain2
i wont when someone time domain2.com in the folder to make a redirect inside domain2 folder
here is what rules i have
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain2.com*
RewriteCond %{REQUEST_URI} !/domain2/
RewriteRule (.*) /domain2/$1

and that works perfect except wehn you try to access folders inside domain2
for example
If i write n browser http://www.domain2.com/test/
everything is just fine
but if i write in browser http://www.domain2.com/test (without slash at the end )
that redirect me to http://www.domain2.com/domain2/test/
Any ideas how i can fix that ?
Menta2K
 
Posts: 4
Joined: Thu Mar 15, 2007 4:27 am

Postby richardk » Fri Mar 16, 2007 1:00 pm

Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

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

Postby Menta2K » Thu Mar 22, 2007 6:33 am

richardk wrote:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

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

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteRule ^(.*)$ /domain2/$1 [QSA,L]



Thanks that almost working except :
when i open domain2.com and clieck on some link on the page like (http://domain2.com/index.php?categoryid ... orgotpwd=1)
its send open domain1.com index.php page
but in browser link is http://domain2.com/index.php?categoryid ... orgotpwd=1

its send
Menta2K
 
Posts: 4
Joined: Thu Mar 15, 2007 4:27 am

Postby Menta2K » Thu Mar 22, 2007 6:44 am

ops its works just perfect it was my mistake

Thanks alot :)
Menta2K
 
Posts: 4
Joined: Thu Mar 15, 2007 4:27 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 105 guests

cron