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
Why is my Apache httpd Alias Not Working? was first published on September 24, 2019.
If you like reading about apache, alias, or httpd then you might also like:
- Fixing Apache (13)Permission denied: access to / 403 Forbidden
- Howto restrict what htaccess files can do on Apache
- Apache Security Patches on CentOS / RHEL
- 20 ways to Secure your Apache Configuration
- CheatSheet for Apache
- Building Apache2 from Source on RedHat Linux 8
Want Security Advisories via Email?
Advisory Week is a new weekly email containing security advisories published by major software vendors (Adobe, Apple, Microsoft, etc).