2 ip's one server rewrite help!!

Using a single web hosting account to host multiple sites

2 ip's one server rewrite help!!

Postby rickvb » Mon Jun 18, 2007 3:35 am

I currently have 2 directory's on one host i want to put together with 2 ip adresses.

I use this code and it works when i go directly to 1.0.0.1, but it doesn't work when i want to acces http://1.0.0.1/css.css

This only works when I use http://1.0.0.1/dir1/css.css

I want to rewrite everything that comes after 1.0.0.1

Code: Select all
Options +FollowSymLinks

RewriteEngine On

#IP 1
RewriteCond %{HTTP_HOST} ^1.0.0.1$ [NC]
RewriteRule ^$ /dir1/ [QSA,L]

#IP 2
RewriteCond %{HTTP_HOST} ^1.0.0.2$ [NC]
RewriteRule ^$ /dir2/ [QSA,L]
rickvb
 
Posts: 2
Joined: Mon Jun 18, 2007 2:38 am

Postby richardk » Mon Jun 18, 2007 11:29 am

If you have access to the httpd.conf file you should use IP-based Virtual Hosts.

The problem with your mod_rewrite is ^$ only matches /.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

#IP 1
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^1\.0\.0\.1$
RewriteRule ^(.*)$ /dir1/$1 [QSA,L]

#IP 2
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^1\.0\.0\.2$
RewriteRule ^(.*)$ /dir2/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby rickvb » Tue Jun 19, 2007 3:52 am

Thanks for the great answer, I will use the httpd.conf virtual hosts so less mod rewriting is needed.
rickvb
 
Posts: 2
Joined: Mon Jun 18, 2007 2:38 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 22 guests

cron