DEV Community

Pete Freitag
Pete Freitag

Posted on • Originally published at petefreitag.com on

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 /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.

Top comments (0)