This is a discussion on Directing Hosts to Different URLs? within the Apache Web Server forums, part of the Web Server and Related Forums category; I'm using Apache 1.3 and want to redirect some URLs to other URLs on a different server. So, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I'm using Apache 1.3 and want to redirect some URLs to other URLs on a
different server. So, at first I used: Redirect permanent /www2 http://10.10.10.103 Redirect permanent /another http://10.10.10.103 That worked fine. But then I realised that some requests are going to be coming from public IP addresses (and not just the VPN as I first thought). Those people need to be redirected to the public IP of the server, and the VPN people can't see that. So I tried: RewriteCond %{REMOTE_ADDR} ^10.10\10.* RewriteRule ^/www2 http://10.10.10.103 [L] RewriteCond %{REMOTE_ADDR} !^10.10.10.* RewriteRule ^/another http://217.205.135.185 [L] But that doesn't work. Not only does everyone get directed to the private IP, but I don't think the redirect rule is going to redirect along the path, so /www2/foo/bar isn't going to go to http://10.10.10.103/foo/bar as I want it to do. I've tried to understand the docs on this, but I'm getting nowhere. Can anyone give me any clues on how to do this? Thanks, Jonathan |
|
|||
|
On 2004-12-14, Jonathan <sorry@this_is_fake.com> wrote:
> But then I realised that some requests are going to be coming from > public IP addresses (and not just the VPN as I first thought). <zap> > But that doesn't work. Not only does everyone get directed to the I see two ways: 1) configure two VirtualHosts, each one listening on one IP, one for the VPN and one for the public IP and use two different set of redirects. This means that if you want to change one redirect you have to change in two places. 2) configure your server as a Proxy, this way doesn't matter where the connection came from, everybody see it as the source of the data. Davide -- He knows all about using Microsoft Word or Excell, and this makes him a skilled computer support person. (The fact that he should be accompanied everywhere by an escort of police motorcycles with sirens warbling "LUSERluserLUSERluserLUSER ..." notwithstanding.) --Charlie |
|
|||
|
Davide Bianchi wrote:
> On 2004-12-14, Jonathan <sorry@this_is_fake.com> wrote: > >>But then I realised that some requests are going to be coming from >>public IP addresses (and not just the VPN as I first thought). > > <zap> > >>But that doesn't work. Not only does everyone get directed to the > > > I see two ways: > 1) configure two VirtualHosts, each one listening on one IP, one for the > VPN and one for the public IP and use two different set of redirects. > This means that if you want to change one redirect you have to change > in two places. > > 2) configure your server as a Proxy, this way doesn't matter where the > connection came from, everybody see it as the source of the data. > Nice - thanks for that. I'll give those a try. It's probably possible with mod_rewrite, but it'll take me a hell of a long time to work it out I think. Jonathan |
|
|||
|
Op Tue, 14 Dec 2004 21:44:24 +0000, schreef Jonathan:
> I'm using Apache 1.3 and want to redirect some URLs to other URLs on a > different server. > So, at first I used: > Redirect permanent /www2 http://10.10.10.103 > Redirect permanent /another http://10.10.10.103 > That worked fine. > But then I realised that some requests are going to be coming from > public IP addresses (and not just the VPN as I first thought). Those > people need to be redirected to the public IP of the server, and the VPN > people can't see that. > So I tried: > > RewriteCond %{REMOTE_ADDR} ^10.10\10.* > RewriteRule ^/www2 http://10.10.10.103 [L] > > RewriteCond %{REMOTE_ADDR} !^10.10.10.* > RewriteRule ^/another http://217.205.135.185 [L] > > But that doesn't work. Not only does everyone get directed to the > private IP, but I don't think the redirect rule is going to redirect > along the path, so /www2/foo/bar isn't going to go to > http://10.10.10.103/foo/bar as I want it to do. > Taking a look at your rewrite directives, I think you can sharpen them a bit. If I understand it correctly, These should be: RewriteCond &{REMOTE_ADDR} ^10\.10\.10\..* RewriteRule ^/www2/(.*) http://10.10.10.103/$1 [L] RewriteCond &{REMOTE_ADDR} !^10\.10\.10\..* RewriteRule ^/another/(.*) http://217.205.135.185/$1 [L] There are two things differently to your approach: - in a regex, a dot (.) matches any character. If you want to match as a dot, you have to escape it. eg \. - you want everything that comes after /www2 to be appended to the new address. This is done by capturing any character that comes after that [-> /www2/(.*)], and appending it to the new constructed address with $1. I haven't tried this, so I'm not sure it'll work, but you can give it a go. -leendert bottelberghs |