[thelist] Apache - alternative paths

Mark Groen evolt at markgroen.com
Thu Dec 14 12:57:41 CST 2006

On Thursday 14 December 2006 09:30, Anthony Baratta wrote:
> Mark...
> Using the ErrorDocument parameter would mean that the script or whatever is
> called only when the requested file does not exist. Not on every request.

But I think that is what the original post was asking for though:
"...Apache so that it looks for a file in a  certain location and, when it 
doesn't find it, source it from a  default folder..."

> > What we were hoping for would be an Apache directive, rather than an
> > external script.

Thought that might be a starting point though as the error directive needs to 
be hit first, but perhaps mod_rewrite rules can only be used in an .htaccess 
file? Never occurred to me, haven't ever tried it myself, but thought this 
might work (change the rewrite rules to what you need, copy/paste example 

Alias /error/ "/var/www/error/"
<IfModule mod_negotiation.c>
<IfModule mod_include.c>
    <Directory "/var/www/error">
        Order allow,deny
        Allow from all
RewriteCond         /your/docroot/dir1/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir1/$1  [L]

#   second try to find it in pub/...
#   ...and if found stop and be happy:
RewriteCond         /your/docroot/dir2/%{REQUEST_FILENAME}  -f
RewriteRule  ^(.+)  /your/docroot/dir2/$1  [L]

#   else go on for other Alias or ScriptAlias directives,
#   etc.
RewriteRule   ^(.+)  -  [PT]

I haven't tested it myself, but the docs say that mod_rewrite should work in 
the httpd.conf as well:



More information about the thelist mailing list