.htaccess tutorial

htaccess Elite


I want to create a 'virtual hosting' situation

Anything not fitting into other categories

I want to create a 'virtual hosting' situation

Postby ti89 » 30 Oct 2006 07:56

http://lists.apple.com/archives/web-dev/2006/Jul/msg00080.html

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]
ti89
 
Posts: 44
Joined: 28 Oct 2006 07:37

Postby cris » 15 Dec 2006 20:55

I have used this script in the .htaccess file and it shows in url http://www.ionescu.nlwww/ so it does not work for me ... yet! and if I try to input http://www.ionescu.nl/ionescu/ the url changes to :

http://ionescu.nl/ionescu/_/ionescu/_/i ... w/ionescu/

plzz help me out
cris
 
Posts: 3
Joined: 15 Dec 2006 20:51


Return to Main