Saturday, October 27, 2007

Alias Directive in Apache HTTP Server

http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias

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 to local files beginning with directory-path. The url-path is case-sensitive, even on case-insenitive file systems.

Example:

Alias /image /ftp/pub/image

A request for http://myserver/image/foo.gif would cause the server to return the file /ftp/pub/image/foo.gif. Only complete path segments are matched, so the above alias would not match a request for http://myserver/imagefoo.gif. For more complex 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 order to expand the alias. That is, if you use Alias /icons/ /usr/local/apache/icons/ then the url /icons will not be aliased.

Note that you may need to specify additional <directory> sections which cover the destination of aliases. Aliasing occurs before <directory> sections are checked, so only the destination of aliases are affected. (Note however <location> sections are run through once before aliases are performed, so they will apply.)

In particular, if you are creating an Alias to a directory outside of your DocumentRoot, you may need to explicitly permit access to the target directory.

Example:

Alias /image /ftp/pub/image
<directory>
Order allow,deny
Allow from all
</directory>


PS: The directive Alias should be inside the tag as in the following example

<IfModule alias_module>

Alias /seagull E:\rungta\workspaces\Eclipse_PDT_Europa\Seagull\www
Alias /project1 E:\rungta\workspaces\Eclipse_PDT_Europa\Project1
</IfModule>

Then set the Target Directory Access permission outside the ifModule Tag


<Directory E:\rungta\workspaces\Eclipse_PDT_Europa\Seagull\www>
Order allow,deny
Allow from all
</Directory>

<Directory E:\rungta\workspaces\Eclipse_PDT_Europa\Project1>
Order allow,deny
Allow from all
</Directory>

No comments: