[Zope] ip redirect
Chris McDonough
chrism@zope.com
Tue, 19 Feb 2002 22:37:59 -0500
Hi Tom,
This is a little lame because it makes the assumption that you always
want to match against a class C network, but as a Python Script:
import string
request = container.REQUEST
RESPONSE = request.RESPONSE
try:
o1,o2,o3,o4=string.split(context.REQUEST['REMOTE_ADDR'], '.', 3)
if [o1,o2,o3] == ['127','0','0']:
RESPONSE.redirect('/redirect.html')
except:
pass
HTH,
- C
Tom Scheidt wrote:
> Hi,
>
> I'm looking for a quick way to redirect users from certain IP addreses as in
> the example below. Notice the wildcard (*). Thanks in advance for your help.
>
> <dtml-if "REMOTE_ADDR == '255.255.2255.*'">
> <dtml-var "RESPONSE.redirect('/redirect_html')">
> </dtml-if>
>
> Tom
>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>
--
Chris McDonough Zope Corporation
http://www.zope.org http://www.zope.com
"Killing hundreds of birds with thousands of stones"