Click to See Complete Forum and Search --> : how to have 2 websites in the same domain changing .htaccess


_LOBO_
09-04-2003, 02:40 AM
My problem is that I want to have to websites www.test1.com and www.test2.com using the same hosting, for example if you write:
www.domain1.com you go to www.domain1.com/subdir/index.htm
www.domain2.com you go to www.domain2.com/subdir2/index.htm

both are in the same server.

I found that this can be achive changing the .htaccess file in the server, and I found this example, Im not and expert making this things and Ihope someone can tell me if this is correct.

Thank you in advance


---------------------CODE----------------------

ORIGINAL

# redirect domain2.com to subdir
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} domain2.com
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ subdir/$1 [L]


MY CHANGES

# redirect test1.com to subdir <--I change here (I think subdir can be changed to my needs right?)
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test1.com <--I change here
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ subdir/$1 [L]

# redirect test2.com to subdir2 <--I change here
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test2.com <--I change here
RewriteCond %{REQUEST_URI} !subdir2/ <--I change here
RewriteRule ^(.*)$ subdir2/$1 [L] <--I change here

-------------------end CODE------------------------

luke0
09-04-2003, 03:43 AM
thats right but and a big but u did something wrong


# redirect test1.com to subdir <--I change here (I think subdir can be changed to my needs right?)
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test1.com <--I change here
RewriteCond %{REQUEST_URI} !subdir/
RewriteRule ^(.*)$ subdir/$1 [L]

# redirect test2.com to subdir2 <--I change here
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test2.com <--I change here
RewriteCond %{REQUEST_URI} !subdir2/ <--I change here
RewriteRule ^(.*)$ $1 [L]









try that

_LOBO_
09-04-2003, 04:53 AM
Thank you luke0

I will try the new code.

_LOBO_

Sux0rZh@jc0rz
09-05-2003, 02:34 PM
omg....luke helped someone....something new everyday.

GavinPearce
09-06-2003, 07:16 AM
luke how da hell did u manage to know that and yet know nothing about anything else?

_LOBO_
09-09-2003, 04:00 AM
hi after test the script I found some errors, here the working script:

# redirect test1.com to sub_1
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} test1.com
RewriteCond %{REQUEST_URI} !sub_1/
RewriteRule ^(.*)$ sub_1/$1 [L]

# redirect test2.com to sub_2
RewriteCond %{HTTP_HOST} test2.com
RewriteCond %{REQUEST_URI} !sub_2/
RewriteRule ^(.*)$ sub_2/$1 [L]

I hope someone can take a look and send me a feedback.

_LOBO_
*I hope this script can help someone in the FORUM. :D