Pete Freitag Pete Freitag

Why is my Apache httpd Alias Not Working?

Published on September 24, 2019
By Pete Freitag

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 /virtual-directory/

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.

apache alias httpd

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:

Weekly Security Advisories Email

Advisory Week is a new weekly email containing security advisories published by major software vendors (Adobe, Apple, Microsoft, etc).