From: Alexei Kosut Date: Tue, 8 Jul 1997 04:45:24 +0000 (+0000) Subject: Enable regex support in mod_alias with AliasMatch, ScriptAliasMatch and X-Git-Tag: APACHE_1_3a1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20e17b7d1354847ca134605b2c1641775454d56f;p=thirdparty%2Fapache%2Fhttpd.git Enable regex support in mod_alias with AliasMatch, ScriptAliasMatch and RedirectMatch directives. New syntax for regex support in http_core: , , sections. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@78559 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/core.html b/docs/manual/mod/core.html index d073f63c0fe..b469c1d447d 100644 --- a/docs/manual/mod/core.html +++ b/docs/manual/mod/core.html @@ -31,10 +31,12 @@ always available.
  • ClearModuleList
  • DefaultType
  • <Directory> +
  • <DirectoryMatch>
  • DocumentRoot
  • ErrorDocument
  • ErrorLog
  • <Files> +
  • <FilesMatch>
  • Group
  • HostNameLookups
  • IdentityCheck @@ -45,6 +47,7 @@ always available.
  • Listen
  • ListenBacklog
  • <Location> +
  • <LocationMatch>
  • LockFile
  • MaxClients
  • MaxKeepAliveRequests @@ -305,7 +308,9 @@ Extended regular expressions can also be used, with the addition of the <Directory ~ "^/www/.*/[0-9]{3}"> -would match directories in /www/ that consisted of three numbers.

    +would match directories in /www/ that consisted of three numbers. In +Apache 1.3 and later, it is reccomended to use +<DirectoryMatch> instead.

    If multiple directory sections match the directory (or its parents) containing a document, then the directives are applied in the order of shortest match @@ -357,6 +362,26 @@ may appear in any configuration file. <Directory> directives cannot nest, and cannot appear in a <Limit> section.


    +

    <DirectoryMatch>

    +Syntax: <DirectoryMatch regex> ... </DirectoryMatch>
    +Context: server config, virtual host
    +Status: Core.
    +Compatibility: Available in Apache 1.3 and later + +

    <DirectoryMatch> and </DirectoryMatch> are used to enclose a group of +directives which will apply only to the named directory and sub-directories +of that directory, the same as <Directory>. However, it takes as an +argument a regular expression. For example:

    + +
    +   <DirectoryMatch "^/www/.*/[0-9]{3}">
    +
    + +

    would match directories in /www/ that consisted of three numbers.

    + +
    +

    DocumentRoot directive

    Syntax: DocumentRoot directory-filename
    @@ -478,7 +503,9 @@ the ~ character. For example:

    <Files ~ "\.(gif|jpe?g|png)$"> -would match most common Internet graphics formats. +would match most common Internet graphics formats. In Apache 1.3 and +later, <FilesMatch> is perferred, +however.

    Note that unlike <Directory> and


    +

    <FilesMatch>

    +Syntax: <FilesMatch regex> +... </Files>
    +Context: server config, virtual host, htaccess
    +Status: core
    +Compatibility: only available in Apache +1.3 and above.

    + +

    The <FilesMatch> directive provides for access control by +filename, just as the <Files> directive +does. However, it accepts a regular expression. For example:

    + +
    +   <FilesMatch "\.(gif|jpe?g|png)$">
    +
    + +

    would match most common Internet graphics formats.

    + +
    +

    Group directive

    Syntax: Group unix-group
    @@ -732,7 +779,8 @@ the

    would match URLs that contained the substring "/extra/data" or -"/special/data".

    +"/special/data". However, in Apache 1.3 and above, use of <LocationMatch> is perferred.

    The Location functionality is especially useful when combined with the


    +

    <LocationMatch>

    + +Syntax: <LocationMatch regex> +... </LocationMatch>
    +Context: server config, virtual host
    +Status: core
    +Compatibility: Location is only available in Apache +1.3 and later.

    + +

    The <LocationMatch> directive provides for access control by +URL, in an identical manner to <Location>. However, it takes a regular +expression as an argument instead of a simple string. For example:

    + +
    +   <LocationMatch "/(extra|special)/data">
    +
    + +

    would match URLs that contained the substring "/extra/data" or +"/special/data".

    + +
    +

    LockFile directive

    Syntax: LockFile filename
    Default: LockFile logs/accept.lock
    diff --git a/docs/manual/mod/directives.html b/docs/manual/mod/directives.html index d65e0056147..3667159927c 100644 --- a/docs/manual/mod/directives.html +++ b/docs/manual/mod/directives.html @@ -33,6 +33,7 @@
  • AddType
  • AgentLog
  • Alias +
  • AliasMatch
  • allow
  • AllowOverride
  • Anonymous @@ -76,6 +77,7 @@
  • DefaultType
  • deny
  • <Directory> +
  • <DirectoryMatch>
  • DirectoryIndex
  • DocumentRoot
  • ErrorDocument @@ -86,6 +88,7 @@
  • ExpiresDefault
  • FancyIndexing
  • <Files> +
  • <FilesMatch>
  • ForceType
  • Group
  • Header @@ -107,6 +110,7 @@
  • LoadFile
  • LoadModule
  • <Location> +
  • <LocationMatch>
  • LockFile
  • LogFormat
  • MaxClients @@ -129,6 +133,7 @@
  • ProxyRequests
  • ReadmeName
  • Redirect +
  • RedirectMatch
  • RedirectPermanent
  • RedirectTemp
  • RefererIgnore @@ -150,6 +155,7 @@
  • ScoreBoardFile
  • Script
  • ScriptAlias +
  • ScriptAliasMatch
  • ScriptLog
  • ScriptLogBuffer
  • ScriptLogLength diff --git a/docs/manual/mod/mod_alias.html b/docs/manual/mod/mod_alias.html index 445c5942f04..484c2b8352f 100644 --- a/docs/manual/mod/mod_alias.html +++ b/docs/manual/mod/mod_alias.html @@ -24,10 +24,13 @@ host filesystem in the the document tree, and for URL redirection.

    Directives


    @@ -64,6 +67,28 @@ See also ScriptAlias.


    +

    AliasMatch

    +

    +Syntax: AliasMatch regex directory-filename
    +Context: server config, virtual host
    +Status: Base
    +Module: mod_alias
    +Compatibility: Available in Apache 1.3 and later +

    + +

    This directive is equivilent to Alias, but +makes use of standard regular expressions, instead of simple prefix +matching. The supplied regular expression is matched against the URL, +and if it matches, the server will substitute any parenthesized +matches into the given string and use it as a filename. For example, +to activate the /icons directory, one might use: +

    +    AliasMatch ^/icons(.*) /usr/local/etc/httpd/icons$1
    +
    +

    + +
    +

    Redirect directive

    @@ -128,6 +153,29 @@ the function send_error_response in http_protocol.c).


    +

    RedirectMatch

    +

    +Syntax: RedirectMatch [status regex url
    +Context: server config, virtual host
    +Status: Base
    +Module: mod_alias
    +Compatibility: Available in Apache 1.3 and later +

    + +

    This directive is equivilent to Redirect, but +makes use of standard regular expressions, instead of simple prefix +matching. The supplied regular expression is matched against the URL, +and if it matches, the server will substitute any parenthesized +matches into the given string and use it as a filename. For example, +to redirect all GIF files to like-named JPEG files on another server, +one might use: +

    +    RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
    +
    +

    + +
    +

    RedirectTemp directive

    @@ -182,6 +230,28 @@ A request for http://myserver/cgi-bin/foo would cause the server to run the script /web/cgi-bin/foo.

    +
    + +

    ScriptAliasMatch

    +

    +Syntax: ScriptAliasMatch regex directory-filename
    +Context: server config, virtual host
    +Status: Base
    +Module: mod_alias
    +Compatibility: Available in Apache 1.3 and later +

    + +

    This directive is equivilent to ScriptAlias, but +makes use of standard regular expressions, instead of simple prefix +matching. The supplied regular expression is matched against the URL, +and if it matches, the server will substitute any parenthesized +matches into the given string and use it as a filename. For example, +to activate the standard /cgi-bin, one might use: +

    +    ScriptAlias ^/cgi-bin(.*) /usr/local/etc/httpd/cgi-bin$1
    +
    +

    +