Hi list,
I am struggling with the following problem. Could someone point me in the right direction with comments or suggestions?
I have a website (A.com) hosted at DNS 12.345.678.999. I want to create a 'virtual hosting' situation for a second website with its own URL (B.com) to be hosted at the same Apache server, along with the first website.
I have created a folder <siteB>, at the root of the server, which contains the website. I want to create an .htaccess document to 'rewrite' the requests for
http://www.b.com AND b.com to go to that folder. I have tried with the following code, and many variations, but do not seem to get it right:
--
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} B.com$
RewriteCond %{REQUEST_URI} !siteB/
RewriteRule ^(.*)$ siteB/$1
--
I would like the redirection to be totally transparent to the user.
Thanks for your help,
Michael
Hey, this seems to work well (.htaccess)!
RewriteEngine On
RewriteBase /
#--- A.com and B.com share the same DNS->IP
#--- All requests to B.com must be directed to the siteB folder
#--- Transparent to the user
RewriteCond %{HTTP_HOST} ^B.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.B.com$ [NC]
RewriteRule ^(.*)$
http://B.com/siteB/$1 [R]
#--- Handling of trailing slash issue with directories
#--- Works for A.com and B.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R]