Apache, Directory Aliases and Virtual Directories

I realized I misconfigured Apache the other day. Apache wasn't serving files from my virtual directory, rather from the root folder named the same. After looking at my Apache configuration, I noted I was missing a leading slash in my Alias directive. Sort of hard to spot, so I hope this helps someone else.

This is the misconfigured version: ( Bad )

view plain print about
1Alias /portal "C:\httpd\Apache2\htdocs\Portal\www"
2<Directory "C:/httpd/Apache2/htdocs/Portal/www">
3 Options Indexes FollowSymLinks MultiViews ExecCGI
4 AllowOverride All
5 Order allow,deny
6 Allow from all
7</Directory>

This is the one that works: ( Good )

view plain print about
1Alias /portal/ "C:/httpd/Apache2/htdocs/Portal/www/"
2<Directory "C:/httpd/Apache2/htdocs/Portal/www">
3 Options Indexes FollowSymLinks MultiViews ExecCGI
4 AllowOverride All
5 Order allow,deny
6 Allow from all
7</Directory>

Note: The slashes have been changed from \ ( Windows Style ) to / ( Unix Style ). For some reason this mattered.....

There are no comments for this entry.

Add Comment Subscribe to Comments

3/22/07 12:05 PM # Sez Robert Carpenter

You might look into the manual regarding the trailing slash too. As you have it now it only sits on one of the refrences to your directory, in the alias command (Alias /portal/ "C:/httpd/Apache2/htdocs/Portal/www/") and not in the directory command (<Directory "C:/httpd/Apache2/htdocs/Portal/www">). I think that they are supposed to be the same -- either both there or both not. Then again it has been a while since I messed with the Alias command and they might have changed it.


8/21/08 1:32 AM # Sez Drale

On my Apache 2.2 install on Windows I did it like this.

Alias /myfolder "C:/path/to/myfolder/"
<Directory "C:/path/to/myfolder/">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

So when I type http://www.mysite.com/myfolder without slash in browser it still loads. If I had "Alias /myfolder/" I am required to type the trailing slash in the browser or I get an error "The requested URL /myfolder was not found on this server.".