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

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.".