redirect on ip adress

redirect on ip adress

am 08.09.2005 10:29:35 von merlin

Hi there,

I would like to redirect all trafic which does not come from a specified IP to
another URL.

Something like this:
RewriteEngine On
RewriteRule ^(.*)$ http://www.newadress.net/

Any idea if this could be done with a regex instead of .* ?

Thanx for any help,

Merlin

Re: redirect on ip adress

am 08.09.2005 14:02:29 von Richard Antony Burton

Merlin wrote:
> I would like to redirect all trafic which does not come from a specified
> IP to another URL.
>
> Something like this:
> RewriteEngine On
> RewriteRule ^(.*)$ http://www.newadress.net/

Try something like this:
RewriteCond %{REMOTE_ADDR} !^127.0.0.1$
RewriteRule ^(.*)$ http://www.newadress.net/

This will rewrite all requests that aren't from the specified ip address.

Richard.

Re: redirect on ip adress

am 09.09.2005 08:37:57 von merlin

Hi,

without the negation it works:
RewriteCond %{REMOTE_ADDR} ^141.62.11.80$

but with negation it does not
RewriteCond %{REMOTE_ADDR} !^141.62.11.80$

I tried to escape the dots but it also did not help. The IP seems to be correct.

Any ideas if the syntax could be different?

Thanx,

Merlin

Richard Antony Burton wrote:
> Merlin wrote:
>
>> I would like to redirect all trafic which does not come from a
>> specified IP to another URL.
>
> >
>
>> Something like this:
>> RewriteEngine On
>> RewriteRule ^(.*)$ http://www.newadress.net/
>
>
> Try something like this:
> RewriteCond %{REMOTE_ADDR} !^127.0.0.1$
> RewriteRule ^(.*)$ http://www.newadress.net/
>
> This will rewrite all requests that aren't from the specified ip address.
>
> Richard.

Re: redirect on ip adress

am 09.09.2005 09:57:59 von Richard Antony Burton

Merlin wrote:
> without the negation it works:
> RewriteCond %{REMOTE_ADDR} ^141.62.11.80$
>
> but with negation it does not
> RewriteCond %{REMOTE_ADDR} !^141.62.11.80$

What do you mean it works without the negation, and not with it? Do you
mean that without the negation it does what you want, but in reverse?
i.e. it redirects requests from that address, but not from everywhere
else? What does your rewrite log show? I did test this, and it does work.

> I tried to escape the dots but it also did not help. The IP seems to be
> correct.

Ah yes, good thinking, though that will only stop a few extra possible
matches, not prevent it matching the one it should.

Richard.

Re: redirect on ip adress

am 09.09.2005 10:17:42 von patpro

In article <3ocpkpF5b80dU1@individual.net>,
Merlin wrote:

> Hi,
>
> without the negation it works:
> RewriteCond %{REMOTE_ADDR} ^141.62.11.80$
>
> but with negation it does not
> RewriteCond %{REMOTE_ADDR} !^141.62.11.80$

did you try :

RewriteCond %{REMOTE_ADDR} !=^141.62.11.80$

or

RewriteCond %{REMOTE_ADDR} !(141.62.11.80)

patpro