[Gllug] Apache URL matching directives, fall through

Richard Lewis richardlewis at fastmail.co.uk
Wed Aug 11 14:06:04 UTC 2010


Hello GLLUG,

I'm trying to configure an Apache set up which matches a few URL
patterns and serves static content "from" (or whichever preposition
you think best) them, and then falls back on a mod_python handler for
all other URLs.

I tried:

<VirtualHost *>
    ServerName localhost
    DocumentRoot /home/richard/app/web

    Alias /static /home/richard/app/web/static
    <Directory /home/richard/app/web/static/>
    	Order allow,deny
     	Allow from all
    </Directory>

    # ... similar directives for /styles, etc.

    <Location />
    	Order allow,deny
    	Allow from all
    	SetHandler mod_python
    	PythonPath 'sys.path+["/home/richard/app/python/"]'
    	PythonHandler handle_request
    </Location>
</VirtualHost>

However, this fails (I think) because <Location> takes precedence over
<Directory>.

So I tried replacing the <Directory>s with <Location>s (and removing
the Aliases):

    <Location /static/*>
	Order allow,deny
	Allow from all
    </Location>

However, the <Location /> still ends up serving every request.

I considered trying a regex for the fall through, mod_python case
(instead of handling just "/"), but all I've come up with so far is a
negative look-behind assertion:

<Location ~ "^/(?<!(static|styles).*$">

which fails because look-behinds must be of fixed width. And anyway, I
don't really want a solution which depends on duplicating knowledge of
the exception cases (i.e. specifying how to handle a subset of
requests, and then re-stating that subset in the default case).

Maybe I'm thinking of Apache directives too much like a collection of
cases in a switch structure?

Any ideas how to get this to work?

Best,
Richard
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Richard Lewis
ISMS, Computing
Goldsmiths, University of London
Tel: +44 (0)20 7078 5134
Skype: richardjlewis
JID: ironchicken at jabber.earth.li
http://www.richardlewis.me.uk/
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+----------------------------------------------+
| Support open access to scholarship           |
| http://freeculture.org/ http://www.doaj.org/ |
+----------------------------------------------+
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list