[mod_python] Re: best practices; was "is mod_python borked?"

Jorey Bump list at joreybump.com
Sun Nov 5 12:53:15 EST 2006

Graham Dumpleton wrote:

> For the first, when a request arrives against a physical directory
> and there is no trailing slash on the URL, Apache (unless it is
> disabled), will send a redirect back to the browser forcing it send
> the request again but with a trailing slash added. By doing this, it
> is helping the browser to understand what the effective base URL is
> such that if relative URLs are then used to address other resources 
> within that directory, it will be able to construct the URL properly.
> Thus, if we have a filesystem structure:
> /some/path/directory /some/path/directory/index.html 
> /some/path/directory/file-1.html
> and we pretend that the URL to access it is the same. If a URL
> arrives which is:
> /some/path/directory
> then Apache sends a redirect back to the browser asking it to
> re-request the resource with the URL:
> /some/path/directory/

An interesting side effect of this is how it affects handlers invoked in 
a Location container:

  <Location /virtual>
     SetHandler python-program
     # module must be in PythonPath!
     PythonHandler virtual
     PythonDebug On

If no corresponding directory exists, the handler can be invoked with or 
without a trailing slash:


But when a matching directory exists, Apache will send a redirect to the 
browser, forcing it to always use:


This has nothing to do with Publisher, but it shows that factors outside 
of mod_python can also have an influence on relative links.

More information about the Mod_python mailing list