[Zope] redirecting from within an access rule

tav tav" <tav@espnow.com
Fri, 22 Jun 2001 06:32:08 +0100


hi there

i am trying to set up an access rule, so that requests to different domains
will be redirected to the "default" domain. e.g.
http://www.espra.com/foo/bar would redirect to http://espra.net/foo/bar,
where "espra.net" is the default domain.

to do this, i have a TinyTable (redirect_index) setup:

----------------------------------
| host_name, redirect_to
----------------------------------
| "espra.org", "espra.net"
| "espra.com", "espra.net"
| "www.espra.org", "espra.net"
| "www.espra.net", "espra.net"
| "www.espra.com", "espra.net"
----------------------------------

and an access rule:

<dtml-in "redirect_index(HTTP_HOST)">
  <dtml-unless "redirect_to == ''">
    <dtml-let to_new_url="_.string.replace(URL0,HTTP_HOST,redirect_to)">
      <dtml-call "REQUEST.RESPONSE.redirect(to_new_url)">
    </dtml-let>
  </dtml-unless>
</dtml-in>

i had hoped that the above would redirect to the "default" domain, if it
found any of the other domains, in the TinyTable

however, the redirect doesn't seem to work as expected within an AccessRule.
it redirects all urls to http://espra.net irrespective of the part after the
server url

e.g. http://www.espra.com/foo/bar would redirect to http://espra.net instead
of redirecting to http://espra.net/foo/bar

so.... what exactly am i doing wrong here?

--
best regards, tav
tav@espnow.com