Module mod_alias

Important: Information for this topic supports the latest PTF levels for HTTP Server for i5/OS . It is recommended that you install the latest PTFs to upgrade to the latest level of the HTTP Server for i5/OS. Some of the topics documented here are not available prior to this update. See http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm Link outside Information Center for more information.

Summary

The module mod_alias provides mapping for different parts of the host filesystem in the document tree and also for URL redirection.

Directives

Alias

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.

Parameter One: url-path
  • The url-path paramter is any valid URL path. If you include a trailing '/' in the URL path, then the server will require a trailing '/' in order to expand the alias. That is, if you use 'Alias /icons/ /www/images/iSeries/icons/' then the URL '/icon' will not be aliased.
Parameter Two: directory-filename
  • The directory-filename parameter is any valid directory/filename combination on the system.
Note: You may need to specify additional <Directory> containers that cover the destination of aliases. Aliasing occurs before <Directory> containers are checked, so only the destination of aliases are affected. <Location> containers are run through once before aliases are performed, so they will apply.

See ScriptAlias for more information.

AliasMatch

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.

Parameter One: regex
  • The regex parameter is a regular expression that is matched against the URL. Subexpressions are grouped within parentheses. Then parenthetically enclosed regular expressions will be substituted in a subsequent $n statement.
Parameter Two: directory-filename
  • The directory-filename parameter is any valid directory/filename that is supported on the iSeries™. If there is a $ symbol (followed by a digit) that is not a substitution variable in the directory-filename parameter, or there is an & symbol in the directory-filename parameter that is part of the directory or filename, the symbol must be escaped (\).

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.

MapMatch

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.

Parameter One: regex
  • The regex paramter is a regular expression that is matched against the URL. Subexpressions are grouped within parentheses. The parenthetically enclosed regular expressions will be substituted in a subsequent $n statement.
Parameter Two: URI
  • The URI paramater is any valid URI that is supported on the iSeries. If there is a $ symbol (followed by a digit) that is not a substitution variable in the URI parameter, or there is an & symbol in the URI parameter that is part of the URI, the symbol must be escaped (\).

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.

Redirect

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.

Parameter One: status
  • The status parameter is used to return the below HTTP status codes:
    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.

Parameter Two: url-path
  • If the url-path has a trailing slash ('/'), the url should also have a trailing slash. If the url-path does not contain a trailing slash, the url should not either. Double check the designated url-path and the url, or a double-slash ('//') may appear in the resulting URL. The url-path must be an absolute path, not a relative path, even when used with .htaccess files or inside of <Directory> containers. The url-path must match the requested resource exactly or be a proper ancestor of it.
Parameter Three: url
  • The url parameter should be a complete URL string, including the scheme ('http://...') and the 'server:host' portion. When the status parameter is "gone", the url argument should be omitted.
Note: Redirect directives take precedence over Alias and ScriptAlias directives, regardless of their order in the configuration file.

RedirectMatch

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.

Parameter One: status
  • The status parameter is used to return the below HTTP status codes:
    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.

Parameter Two: regex
  • The regex parameter is aregular expression that is matched against the URL. Subexpressions are grouped within parentheses. Then, parenthetically enclosed regular expressions will be substituted in a subsequent $n statement.
Parameter Three: url
  • The url parameter should be a complete URL string, including the scheme ('http://...') and the 'server:port' portion. If there is a $ symbol (followed by a digit) that is not a substitution variable in the url parameter, or there is a & symbol in the url parameter that is part of the URL, the symbol must be escaped (\).

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.

RedirectPermanent

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.

Parameter One: url-path
  • The url-path parameter is any valid URL path. If you include a trailing '/' in the URL path, then the server will require a trailing '/' in order to expand the alias. That is, if you use 'Alias /icons/ /www/images/iSeries/icons/' then the URL '/icon' will not be aliased.
Parameter Two: url
  • The url parameter should be a complete URL string, including the scheme ('http://...') and the 'server:host' portion. When the status parameter is "gone", the url argument should be omitted.

See Regular expression notation for HTTP Server for more information.

RedirectTemp

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.

Parameter One: url-path
  • The url-path parameter is any valid URL path. If you include a trailing '/' in the URL path, then the server will require a trailing '/' in order to expand the alias. That is, if you use 'Alias /icons/ /www/images/iSeries/icons/' then the URL '/icon' will not be aliased.
Parameter Two: url
  • The url parameter should be a complete URL string, including the scheme ('http://...') and the 'server:host' portion. When the status parameter is "gone", the url argument should be omitted.

See Regular expression notation for HTTP Server for more information.

ScriptAlias

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.

Parameter One: url-path
  • The url-path parameter is any valid url-path. It must end with a slash ('/') character so that any files in the directory will be routed.
Parameter Two: directory-filename
  • The directory-filename parameter is any valid directory/filename on the iSeries.
Note: If the URL ends in a slash ("/") character, the ScriptAlias must also end in a slash character.

ScriptAliasMatch

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.

Parameter One: regex
  • The regex parameter is a regular expression that is matched against the URL. Subexpressions are grouped within parentheses. Then, parenthetically enclosed regular expressions will be substituted in a subsequent $n statement.
Parameter Two: directory-filename
  • This is any valid directory/filename that is supported on the iSeries. If there is a $ symbol (followed by a digit) that is not a substitution variable in the directory-filename parameter, or there is a & symbol in the directory-filename parameter that is part of the directory or filename, the symbol must be escaped (\).

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