13.06.2015 Views

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

Introduction to the Apache Web Server - ApacheCon

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8.3 Alias<br />

• Maps a URL <strong>to</strong> a direc<strong>to</strong>ry, often outside of <strong>the</strong> DocumentRoot direc<strong>to</strong>ry<br />

Used <strong>to</strong> map a URL <strong>to</strong> a direc<strong>to</strong>ry - usually a direc<strong>to</strong>ry outside of <strong>the</strong> main document direc<strong>to</strong>ry, although<br />

this is not necessarily <strong>the</strong> case. The default distro, for example, comes with an Alias for <strong>the</strong> documentation<br />

(/manual) which points <strong>to</strong> a direc<strong>to</strong>ry within <strong>the</strong> document root. This is so that you can move it if you want<br />

<strong>to</strong>, but is really ra<strong>the</strong>r redundant. For one release (1.3.25 perhaps?) /manual actually did move outside of<br />

<strong>the</strong> document root, but it moved back in <strong>the</strong> next release because it irritated people who don’t like change.<br />

The Alias for /icons/, on <strong>the</strong> o<strong>the</strong>r hand, points <strong>to</strong> a direc<strong>to</strong>ry that has always been outside of <strong>the</strong> document<br />

root.<br />

Important note about Alias. The slashes must match. That is, if <strong>the</strong> first argument contains a slash, <strong>the</strong><br />

second one should also. Thus:<br />

Alias /foo /var/www/foo<br />

Note that <strong>the</strong> first argument (/foo) has no trailing slash, and, thus, <strong>the</strong> second argument (/var/www/foo)<br />

also should not. When <strong>the</strong> slashes don’t match, bad things happen. Alias is taken very literally. The string<br />

in <strong>the</strong> URL is replaced verbatim with <strong>the</strong> argument provided. This can result in file paths with <strong>to</strong>o many<br />

slashes, or two few, depending on which side you erred.<br />

For example, if you have:<br />

Alias /icons/ /usr/local/apache/icons<br />

You will end up with errors in your logs which say something like:<br />

File /usr/local/apache/iconssomething.gif not found<br />

Note <strong>the</strong> missing / between icons and something.gif. That’s your clue that this is what is happening.<br />

8.4 ScriptAlias<br />

• Maps a URL <strong>to</strong> a direc<strong>to</strong>ry, and indicates that <strong>the</strong> direc<strong>to</strong>ry contains CGI programs<br />

ScriptAlias /cgi-bin/ /usr/local/apache/cgi-bin/<br />

44

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!