[mod_python] redirects and url rewriting

Daniel J. Popowich dpopowich at mtrsd.k12.ma.us
Mon Dec 22 15:36:01 EST 2003


Michael S. Fischer writes:
> I wrote:
> 
> > Browsers determine what to display in the address bar based on two 
> > things only: (1) the URL requested by a user (bookmark, address bar or 
> > some other UI mechanism), or (2) an HTTP Redirect: header returned by 
> > the server.
> 

Yes, of course.  Duh.  I now think I understand what's going on:

  1. A call to req.internal_redirect(uri) will return the content of
     the uri as the address the user asked for UNLESS the HTTP
     Location header is sent.  This is what I had been originally
     expecting until the redirect to certain urls (like
     http://localhost/manual) changed in my browser's address bar.
     Confusion insued until Kevin Ballard replied with clues that...

  2. ...apache, when receiving requests that are directories (or
     aliases/symlinks to directories) without the trailing slash,
     actually sends a 301 response.  So, a request like
     http://host/foo will generate a 301 response if foo is a
     directory and send a "Location: http://host/foo/" header.  I was
     first shocked by this (think of all the extra bytes flooding the
     'net because of this!!), but understand it's the only way within
     the protocol to make relative links work.  (Although it begs the
     question why the protocol doesn't have a Real-Location header, or
     some such, to let the browser know what the real url for the
     requested page should be without having to go fetch it.)

Sound right?

Knowing now what I can expect consistantly (and knowing it's not for
lack of understanding mod_python subtleties) and can continue with my
app design.  Thanks for all your help!

Dan




More information about the Mod_python mailing list