ScriptAliasMatch
ScriptAliasMatch regex directory
Server config, virtual host
This directive is equivalent to ScriptAlias
but
makes use of standard regular expressions instead of simple prefix
matching. The supplied regular expression is matched against the URL;
if it matches, the server will substitute any parenthesized matches
into the given string and use the result as a filename. For example,
to activate any script in /cgi-bin, one might
use the following:
ScriptAliasMatch /cgi-bin/(.*) /usr/local/apache/cgi-bin/$1
If the user is sent by a link to
http://www.butterthlies.com/cgi-bin/script3,
"/cgi-bin/“matches against /cgi-bin/
. We then
have to match script3 against
.*
, which works, because
“.” means any character and
“*” means any number of whatever
matches “.”. The parentheses around
.*
tell Apache to store whatever matched to
.*
in the variable $1
. (If some
other pattern followed, also surrounded by parentheses, that would be
stored in $2
). In the second part of the line,
ScriptAliasMatch
is told, in effect, to run
/usr/local/apache/cgi-bin/script3
.