DEV Community

Pete Freitag
Pete Freitag

Posted on • Originally published at petefreitag.com on

2 2

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.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more