X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=docs%2Fmanual%2Fmod%2Fmod_alias.html.en;h=295c1f2d6d405a8fe80abe45091374c13319884b;hb=430aadce59b536d533be35d333eebfe579a94d16;hp=64f52189334c4a83feb523252312663314caf08c;hpb=1b2cc09c0463b5ee9013c36673e75b72a26bf9e6;p=apache diff --git a/docs/manual/mod/mod_alias.html.en b/docs/manual/mod/mod_alias.html.en index 64f5218933..295c1f2d6d 100644 --- a/docs/manual/mod/mod_alias.html.en +++ b/docs/manual/mod/mod_alias.html.en @@ -5,19 +5,22 @@ This file is generated from xml source: DO NOT EDIT XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --> -
Apache HTTP Server Version 2.3
+ +Apache HTTP Server Version 2.5
When the Alias
,
+ ScriptAlias
and
+ Redirect
directives are used
+ within a <Location>
+ or <LocationMatch>
+ section, expression syntax can be used
+ to manipulate the destination path or URL.
+
mod_alias
is designed to handle simple URL
manipulation tasks. For more complicated tasks such as
manipulating the query string, use the tools provided by
mod_rewrite
.
Aliases and Redirects occuring in different contexts are processed +
Aliases and Redirects occurring in different contexts are processed
like other directives according to standard merging rules. But when multiple
Aliases or Redirects occur in the same context (for example, in the
same <VirtualHost>
@@ -94,24 +106,33 @@
all the directives to have an effect. For example, the following
configuration will work as expected:
- Alias /foo/bar /baz
- Alias /foo /gaq
-
Alias "/foo/bar" "/baz" +Alias "/foo" "/gaq"+
But if the above two directives were reversed in order, the
/foo
Alias
would always match before the /foo/bar
Alias
, so the latter directive would be
ignored.
When the Alias
,
+ ScriptAlias
and
+ Redirect
directives are used
+ within a <Location>
+ or <LocationMatch>
+ section, these directives will take precedence over any globally
+ defined Alias
,
+ ScriptAlias
and
+ Redirect
directives.
Description: | Maps URLs to filesystem locations | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Syntax: | Alias URL-path
+ |
The Alias
directive allows documents to
be stored in the local filesystem other than under the
DocumentRoot
. URLs with a
- (%-decoded) path beginning with url-path will be mapped
+ (%-decoded) path beginning with URL-path will be mapped
to local files beginning with directory-path. The
- url-path is case-sensitive, even on case-insensitive
+ URL-path is case-sensitive, even on case-insensitive
file systems.
- Alias /image /ftp/pub/image
-
Alias "/image" "/ftp/pub/image"+
A request for http://example.com/image/foo.gif
would cause
the server to return the file /ftp/pub/image/foo.gif
. Only
@@ -135,14 +155,15 @@
matching using regular expressions, see the AliasMatch
directive.
Note that if you include a trailing / on the - url-path then the server will require a trailing / in + URL-path then the server will require a trailing / in order to expand the alias. That is, if you use
-Alias /icons/ /usr/local/apache/icons/
Alias "/icons/" "/usr/local/apache/icons/"+
then the url /icons
will not be aliased, as it lacks
that trailing /. Likewise, if you omit the slash on the
- url-path then you must also omit it from the
+ URL-path then you must also omit it from the
file-path.
Note that you may need to specify additional <Directory>
sections which
@@ -157,14 +178,28 @@
directory outside of your DocumentRoot
, you may need to explicitly
permit access to the target directory.
- Alias /image /ftp/pub/image
- <Directory /ftp/pub/image>
-
- Require all granted
-
- </Directory>
-
Alias "/image" "/ftp/pub/image" +<Directory "/ftp/pub/image"> + Require all granted +</Directory>+ + +
Any number slashes in the URL-path parameter + matches any number of slashes in the requested URL-path.
+ +If the Alias
directive is used within a
+ <Location>
+ or <LocationMatch>
+ section the URL-path is omitted, and the file-path is interpreted
+ using expression syntax.
<Location "/image"> + Alias "/ftp/pub/image" +</Location> +<LocationMatch "/error/(?<NUMBER>[0-9]+)"> + Alias "/usr/local/apache/errors/%{env:MATCH_NUMBER}.html" +</LocationMatch>+
/icons
directory, one might
use:
-
- AliasMatch ^/icons(.*) /usr/local/apache/icons$1
-
AliasMatch "^/icons(/|$)(.*)" "/usr/local/apache/icons$1$2"+
The full range of regular expression power is available. For example, it is possible to construct an alias with case-insensitive - matching of the url-path:
+ matching of the URL-path: + +AliasMatch "(?i)^/image(.*)" "/ftp/pub/image$1"-
- AliasMatch (?i)^/image(.*) /ftp/pub/image$1
-
One subtle difference
between Alias
@@ -212,7 +245,7 @@ expressions
regular expression to match the entire request URI from beginning
to end, and to use substitution on the right side.
In other words, just changing +
In other words, just changing
Alias
to
AliasMatch
will not
have the same effect. At a minimum, you need to
@@ -222,22 +255,19 @@ expressions
For example, suppose you want to replace this with AliasMatch:
-
- Alias /image/ /ftp/pub/image/
-
Alias "/image/" "/ftp/pub/image/"+
This is NOT equivalent - don't do this! This will send all requests that have /image/ anywhere in them to /ftp/pub/image/:
-
- AliasMatch /image/ /ftp/pub/image/
-
AliasMatch "/image/" "/ftp/pub/image/"+
This is what you need to get the same effect:
-
- AliasMatch ^/image/(.*)$ /ftp/pub/image/$1
-
AliasMatch "^/image/(.*)$" "/ftp/pub/image/$1"+
Of course, there's no point in
using AliasMatch
@@ -246,10 +276,14 @@ expressions
you do more complicated things. For example, you could
serve different kinds of files from different directories:
- AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg
- AliasMatch ^/image/(.*)\.gif$ /files/gif.images/$1.gif
-
AliasMatch "^/image/(.*)\.jpg$" "/files/jpg.images/$1.jpg"+ + +
+AliasMatch "^/image/(.*)\.gif$" "/files/gif.images/$1.gif"
Multiple leading slashes in the requested URL are discarded + by the server before directives from this module compares + against the requested URL-path. +
Description: | Sends an external redirect asking the client to fetch a different URL | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Syntax: | Redirect [status] URL-path
+ |
Description: | Maps a URL to a filesystem location and designates the target as a CGI script | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Syntax: | ScriptAlias URL-path
+ |
- ScriptAlias /cgi-bin/ /web/cgi-bin/
-
ScriptAlias "/cgi-bin/" "/web/cgi-bin/"+
A request for http://example.com/cgi-bin/foo
would cause the
server to run the script /web/cgi-bin/foo
. This configuration
is essentially equivalent to:
- Alias /cgi-bin/ /web/cgi-bin/
- <Location /cgi-bin >
-
- SetHandler cgi-script
- Options +ExecCGI
-
- </Location>
-
Alias "/cgi-bin/" "/web/cgi-bin/" +<Location "/cgi-bin"> + SetHandler cgi-script + Options +ExecCGI +</Location>+
ScriptAlias
can also be used in conjunction with
a script or handler you have. For example:
- ScriptAlias /cgi-bin/ /web/cgi-handler.pl
-
ScriptAlias "/cgi-bin/" "/web/cgi-handler.pl"+ +
In this scenario all files requested in /cgi-bin/
will be
- handled by the file you have configured, this allows you to use your own custom
- handler. You may want to use this as a wrapper for CGI so that you can add
+ handled by the file you have configured, this allows you to use your own custom
+ handler. You may want to use this as a wrapper for CGI so that you can add
content, or some other bespoke action.
ScriptAlias
. Instead, use <Directory>
, SetHandler
, and Options
as in:
-
- <Directory /usr/local/apache2/htdocs/cgi-bin >
-
- SetHandler cgi-script
- Options ExecCGI
-
- </Directory>
-
<Directory "/usr/local/apache2/htdocs/cgi-bin"> + SetHandler cgi-script + Options ExecCGI +</Directory>+ This is necessary since multiple URL-paths can map to the same filesystem location, potentially bypassing the
ScriptAlias
and revealing the source code
of the CGI scripts if they are not restricted by a
Directory
section.If the ScriptAlias
directive is used within
+ a <Location>
+ or <LocationMatch>
+ section with the URL-path omitted, then the URL parameter will be
+ interpreted using expression syntax.
<Location "/cgi-bin"> + ScriptAlias "/web/cgi-bin/" +</Location> +<LocationMatch "/cgi-bin/errors/(?<NUMBER>[0-9]+)"> + ScriptAlias "/web/cgi-bin/errors/%{env:MATCH_NUMBER}.cgi" +</LocationMatch>+ +
+
/cgi-bin
, one
might use:
-
- ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
-
ScriptAliasMatch "^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"+
As for AliasMatch, the full range of regular expression power is available. For example, it is possible to construct an alias with case-insensitive - matching of the url-path:
+ matching of the URL-path: + +ScriptAliasMatch "(?i)^/cgi-bin(.*)" "/usr/local/apache/cgi-bin$1"-
- ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
-
The considerations related to the difference between
Alias
and
@@ -548,7 +605,28 @@ and designates the target as a CGI script
ja |
ko |
tr