0

I have a domains test1.xxxxxx.com, test2.xxxxxx.com, test3.xxxxxx.com and so on which point to my DMZ ip address.

On my DMZ I have an apache web server.

The apache web server needs to redirect

test1.xxxxxx.com to test1.xxxxxx.com (192.168.1.1) on the internal network
test2.xxxxxx.com to test2.xxxxxx.com (192.168.1.2) on the internal network
test3.xxxxxx.com to test3.xxxxxx.com (192.168.1.3) on the internal network

The mapping for test1.xxxxxx.com to 192.168.1.1 and so on is specified in hosts file

I have

<VirtualHost *:80>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(test1.xxxxxx.com)$
RewriteRule ^(.*)$ http://test1.xxxxxx.com [R,L]

RewriteCond %{HTTP_HOST} ^(test2.xxxxxx.com)$
RewriteRule ^(.*)$ http://test2.xxxxxx.com [R,L]

RewriteCond %{HTTP_HOST} ^(test3.xxxxxx.com)$
RewriteRule ^(.*)$ http://test3.xxxxxx.com [R,L]
</VirtualHost>

When I try to hit http://test1.xxxxxx.com in browser I get This webpage has a redirect loop

If I have

<VirtualHost *:80>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(test1.xxxxxx.com)$
RewriteRule ^(.*)$ http://test2.xxxxxx.com [R,L]

</VirtualHost>

Then the rewrite works.

Something similar used to work, but I changed my server and above does not work. What do I need to tweak to make this work.

Thanks in advance

smehta
  • 1
  • 1

2 Answers2

0

Seems like you are using 2 times the same domain. If test1.xxxxxx.com redirect to test1.xxxxxx.com that will still resolve to that dmz address (it's the same domain!) and loops till the browser decides it's enough :)

In your example where it "worked", you had different url on both lines test1.xxxxxx.com to test2.xxxxxx.com which resolves to different ip.

ROunofF
  • 717
  • 5
  • 19
0

Resolved using

<VirtualHost *:80>
    RewriteEngine on

    RewriteCond %{HTTP_HOST}   ^test1\.xxxxxx\.com [NC]
    RewriteCond %{HTTP_HOST}   !^$
    RewriteRule ^/?(.*)         http://test1.xxxxxx.com/$1 [L,R,NE,P]
</VirtualHost>

Now works as I require it

smehta
  • 1
  • 1