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 )

Alias /portal "C:\httpd\Apache2\htdocs\Portal\www"
<Directory "C:/httpd/Apache2/htdocs/Portal/www">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

This is the one that works: ( Good )

Alias /portal/ "C:/httpd/Apache2/htdocs/Portal/www/"
<Directory "C:/httpd/Apache2/htdocs/Portal/www">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>

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

Comments
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.
# Posted By Robert Carpenter | 3/22/07 12:05 PM
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.".
# Posted By Drale | 8/21/08 1:32 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.001. Contact Blog Owner