Summary
The module mod_alias provides mapping for different parts of the host filesystem in the document tree and also for URL redirection.
Directives
Module: mod_alias | |
Syntax: Alias url-path directory-filename | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: Alias /image /QIBM/UserData/pub/image | |
Example: Alias /httpfile/ /QSYS.LIB/AS400LIB.LIB/HTML.FILE/ |
This directive allows documents to be stored in the local filesystem other than under the DocumentRoot. URLs with a (%-decoded) path beginning with the value of the URL-path parameter will be mapped to local files beginning with the value of directory-filename. Alias also allows you to hide the file system path from users, enhancing both security of your server and the ability to change the filesystem structure or paths without impacting the end users.
See ScriptAlias for more information.
Module: mod_alias | |
Syntax: AliasMatch regex directory-filename | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: AliasMatch ^/icons(.*) /www/images/HTTP_Server/icons$1 | |
Example: AliasMatch ^/lib/docs(.*) /QSYS.LIB/DOCLIB.LIB/HTMLDOC.FILE/$1.MBR |
This directive is equivalent 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.
If the directory-filename is /usr/local/apache/icons&gifs/ the & would need to be escaped as follows on the AliasMatch directive:
AliasMatch ^/icons(.*) /usr/local/apache/icons\gifs/
If the directory-filename is /usr/local/apache/icon$1/ the $ would need to be escaped as follows on the AliasMatch directive:
AliasMatch ^/icons(.*) /usr/local/apache/icon\$1/
See Regular expression notation for HTTP Server for more information.
Module: mod_alias | |
Syntax: MapMatch regex URI | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: MapMatch ^/icons(.*) /www/apache/icons\&gifs/ |
The MapMatch directive uses standard regular expressions to change a URI to a different URI. 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 the URI. This is not a terminating directive. The server will use the new URI as input to Alias, Redirect or other MapMatch directives.
If the target URI is /www/apache/icons\&gifs/ the & would need to be escaped as follows on the MapMatch directive:
MapMatch ^/icons(.*) /www/apache/icons\&gifs/
If the target URI is /www/apache/icon$1/ the $ would need to be escaped as follows on the MapMatch directive:
MapMatch ^/icons(.*) /www/apache/icon\$1/
See Regular expression notation for HTTP Server for more information.
Module: mod_alias | |
Syntax: Redirect [status] url-path url | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: Redirect /service http://foo2.bar.com/service |
The Redirect directive maps an old URL into a new one. The new URL is returned to the client, who then attempts to access the page with the new address. URL-path is a (%-decoded) path; any requests for documents beginning with this path will be returned with a redirect error to a new (%-encoded) URL beginning with url.
Status | Description |
---|---|
permanent | Returns a permanent redirect status (301) indicating that the resource has moved permanently. |
temp | Returns a temporary redirect status (302). This is the default. |
seeother | Returns a "See Other" status (303) indicating that the resource has been replaced. |
gone | Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the url argument should be omitted. |
If no status argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily. Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the url argument must be present, otherwise it must be omitted. Regardless, any HTTP status given must be known to HTTP Server.
Module: mod_alias | |
Syntax: RedirectMatch [status] regex url | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg |
This directive is equivalent 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.
Status | Description |
---|---|
permanent | Returns a permanent redirect status (301) indicating that the resource has moved permanently. |
temp | Returns a temporary redirect status (302). This is the default. |
seeother | Returns a "See Other" status (303) indicating that the resource has been replaced. |
gone | Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the url argument should be omitted. |
If no status argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily. Other status codes can be returned by giving the numeric status code as the value of status. If the status is between 300 and 399, the url argument must be present, otherwise it must be omitted. Regardless, any HTTP status given must be known to HTTP Server.
If the URL to redirect to is http://www.anotherserver.com/cgi-bin/welcome.cgi?parm1=login&parm2=mainlist the & would need to be escaped as follows on the RedirectMatch directive:
RedirectMatch(.*) http://www.anotherserver.com/cgi-bin/welcome.cgi?parm1=login\&parm2=mainlist
If the URL to redirect to is http://www.anotherserver.com/htdocs/welcome$2login.html the $2 would need to be escaped as follows on the RedirectMatch directive:
RedirectMatch (.*) http://www.anotherserver.com/htdocs/welcome\$2login.html
See Regular expression notation for HTTP Server for more information.
Module: mod_alias | |
Syntax: RedirectPermanent url-path url | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RedirectPermanent /payroll http://payroll.server.com/payroll |
The RedirectPermanent directive notifies the client that the Redirect is permanent (status 301). This is the exact equivalent to Redirect permanent.
See Regular expression notation for HTTP Server for more information.
Module: mod_alias | |
Syntax: RedirectTemp url-path url | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: RedirectTemp /service http://foo2.bar.com/service |
The RedirectTemp directive notifies the client that the Redirect is only temporary (status 302). This is the exact equivalent to Redirect temp.
See Regular expression notation for HTTP Server for more information.
Module: mod_alias | |
Syntax: ScriptAlias url-path directory-filename | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: ScriptAlias /cgi-bin/ /web/cgi-bin/ | |
Example: ScriptAlias /cgi-bin/ /QSYS.LIB/QSYSCGI.LIB/ |
The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts, and then executes the CGI program. URLs with a (%-decoded) path beginning with url-path will be mapped to scripts beginning with directory-filename. Additional <Directory> containers that cover the destination of the ScriptAlias may need to be specified. Aliasing occurs before <Directory> containers are checked, so only the destination of Aliases are affected.
Module: mod_alias | |
Syntax: ScriptAliasMatch regex directory-filename | |
Default: none | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: ScriptAliasMatch ^/cgi-bin/(.*)\.cgi /QSYS.LIB/QSYSCGI.LIB/$1.PGM |
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, and if it matches, the server will substitute any parenthesized matches into the given string and use it as a filename.
If the directory-filename is /usr/local/apache/cgi-bin&sym/$1.pgm, where the $1 is a substitution variable, the & would need to be escaped as follows on the ScriptAliasMatch directive:
ScriptAliasMatch ^/cgi-bin/(.*)\.cgi /usr/local/apache/cgi-bins\&sym/$1.pgm
If the directory-filename is /usr/local/apache/cgi-bin$2sym/ $1.pgm, where the $1 is a substitution variable, the $2 would need to be escaped as follows on the ScriptAliasMatch directive:
ScriptAliasMatch ^/cgi-bin/(.*)\.cgi /usr/local/apache/cgi-bin\$2sym/$1.pgm