19.3 mod_alias

Team-Fly    

 
Webmaster in a Nutshell, 3rd Edition
By Robert Eckstein, Stephen Spainhour
Table of Contents
Chapter 19.  Apache Modules


The mod_alias module assists filesystem mapping and URL redirection.

Alias

  Alias   symbolic_path  real_path 

[ server config , within <VirtualHost>]

Creates a virtual name or directory by mapping a symbolic path that is used in a URL to a real path on the server. Aliasing is useful for organizing server documents, keeping URLs simpler for users, and hiding the structure of a filesystem. For example, the icon directory is aliased in the default configuration file:

 Alias /icons /usr/local/etc/httpd/icons 

With this setting, a request for /icons/image.gif is handled by sending back the file /usr/local/etc/httpd/icons/image.gif . If you specify a trailing slash on the symbolic path , the client must also enter that slash for the alias to take effect.

AliasMatch

  AliasMatch   regex  real_path 

[ server config , within <VirtualHost>]

Similar to Alias but uses regular expressions. This option creates a virtual name or directory by mapping a symbolic pathname that matches the standard regular expression, regex , to a real path on the server. For example:

 AliasMatch ^/images(.*) /etc/httpd/server/images 
Redirect

  Redirect  [  status  ] pathname url 

Tells the server to forward clients that request a given directory or document, pathname , to a new location, specified by url . This new location must be a complete path, unless the status given is gone, in which case the new location must be omitted. The Redirect directive supersedes any Alias or AliasMatch directives that are specified.

The status variable can be one of the following:

permanent

This option uses an HTTP status 301 to indicate to the client that the redirect should be considered permanent.

temp

This option uses an HTTP status 302 to indicate to the client that the redirect is only temporary. This is the default.

seeother

This option uses an HTTP status 303 to indicate to the client that the resource requested has been superseded or replaced .

gone

This option uses an HTTP status 410 to indicate to the client that the resource has been removed.

RedirectMatch

  RedirectMatch  [  status  ] regex url 

Similar to Redirect but uses standard regular expressions. This option tells the server to forward clients that request a directory or document matching the regular expression regex to a new location, specified by url . For example:

 RedirectMatch (.*).jpg http://imageserver.mycorp.com.jpg 
RedirectPermanent

  RedirectPermanent   url-path  url  srm.conf  

Equivalent to Redirect with a status of permanent.

RedirectTemp

  RedirectTemp   url-path  url 

Equivalent to Redirect with a status of temp.

ScriptAlias

  ScriptAlias   symbolic_path  real_path 

[ server config , within <VirtualHost>]

Creates a virtual directory of CGI programs by mapping a symbolic pathname that is used in a URL to a real directory of executable CGI programs on your server. Instead of returning a document in that directory, the server runs a requested file within a CGI environment and returns the output. For example:

 ScriptAlias /cgi-bin/ /usr/local/frank/cgi-bin/ 

See Chapter 12, for more information on CGI.

ScriptAliasMatch

  ScriptAliasMatch   regex  filename 

[ server config , within <VirtualHost>]

Similar to ScriptAlias, but uses regular expressions. This option creates a virtual directory of CGI programs by mapping any symbolic pathnames that match the standard regular expression regex to a real directory of executable CGI programs on the server. For example:

 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/frank/cgi-bin 

See Chapter 12 for more information on CGI.


Team-Fly    
Top


Webmaster in a Nutshell
Webmaster in a Nutshell, Third Edition
ISBN: 0596003579
EAN: 2147483647
Year: 2002
Pages: 412

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net