Why is my Apache httpd Alias Not Working?
Ran into this today, so I thought I would blog it.
I had an alias in my httpd.conf such as:
Alias /virtual-directory /path/to/files
I had to change the alias to point to a new folder so I commented out the old one and added a new one like this:
Alias /virtual-directory/ /different/path/to/files
And now my
Alias was not working! I was getting a 404 status code response.
One reason an Alias might fail when you change directories could be if the
Directory directive did not allow access to that folder, but that was not the case here and that would probably cause a 403 response not a 404.
Maybe you have already spotted the problem in my example, but I found the problem by looking at the Apache server error logs. I had an entry like:
File does not exist: /different/path/to/filesindex.html
As you can see now, my first (working Alias) was set for the URI
/virtual-directory but my second one had a trailing slash
The moral of the story is to make sure that the trailing slashes match for the alias and its path, otherwise you might run into this issue.
Like this? Follow me ↯Tweet Follow @pfreitag
You might also like:
- Fixing Apache (13)Permission denied: access to / 403 Forbidden - July 21, 2011
- Howto restrict what htaccess files can do on Apache - September 4, 2019
- Apache Security Patches on CentOS / RHEL - November 22, 2013
- 20 ways to Secure your Apache Configuration - December 6, 2005
- CheatSheet for Apache - October 7, 2005
- Building Apache2 from Source on RedHat Linux 8 - June 4, 2003