Setting up an alias in Apache
Alias module in Apache http server provides an easy way to map a URL path to a local file directory. For example, the popular MySQL web access tool phpMyAdmin is often installed as a alias in the Apache web server. Usually a line of code like this will do the trick:
alias /phpMyAdmin “/my/directory/phpMyAdmin”
Recently I tried to setup a new server in the same way but kept getting 403 forbidden (You don’t have permission to access /phpMyAdmin on this server) message from the web server. Thinking that this must have been some trivial issue like a typo, it turned out to be a long troubleshooting process. Finally I figured out the couple of things that needed to be fixed:
First, the directory access permission needs to be set up correctly.
The default directory access permission is usually set pretty strict. It looks like this:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
It provides good security but also prevents the access to the others. So we’ll have to re-configure the directory that is mapped to an alias (Same should be done for the virtual server as well). So adding this into the httpd.conf will make it better:
<Directory “/my/directory/phpMyAdmin”>
Options All -Indexes
AllowOverride all
Order allow,deny
Allow from all
</Directory>
However, I was still getting the error: You don’t have permission to access /phpMyAdmin on this server, which was quite puzzling since I was pretty sure I was on the right track.
Now this time even the error message was the same it was a different cause. Since I disallowed file listing on the directory (-Indexes) Apache refused to server the URI …/phpMyAdmin. All I needed to do was to add index.php to the DirectoryIndex directive so Apache knows what to display when a directory name is requested. Of course …/phpMyAdmin/index.php would also work without the change.
A seemingly small problem caused me a lot of time to fix.