Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple virtual host in one server and plan to has some alias setup in one virtualhost.

So I add the

Alias /foo/ /path/to/foo/

in virtualhost directive,but it has no effect. Request of host1/foo/ will return 404. But if I add this to /etc/apache2/mods-available/alias.conf, it works. But the problem is host2 will also share this alias.

Is there a way to make the alias work only for host1?

BTW, I use apache2ctl -l, there's no mod_alias.c listed, weird.

share|improve this question
can you post your alias.conf and apache2.conf/httpd.conf and log file to – vsltd Apr 13 '11 at 7:58
what os you are running on? – Bernd Ott Apr 13 '11 at 12:00
Is /path/to/foo/ an empty directory? If there's no index.html file there (or whatever your DirectoryIndex directive is set to) then a 404 is the correct response. Try putting a file in that directory and then requesting it with something like http://host1/foo/file.html. – Ladadadada Nov 9 '13 at 18:38

This worked for me:

Alias /test /tmp/test

Notice that no shashes at the end of paths. But I don't know the reason of this effect.

share|improve this answer
that's the exact one i use at first, but unfortunately it doesn't work. and then i add slash, make a request with host1/test/, still 404. Is your apache's configuration layout also the split version(apache2.conf, mod-enable, mod-available, conf.d,etc)? I know this works for the traditional monolithic configuration such as httpd.conf. – 0x7c00 Apr 13 '11 at 8:00
Have a look if a file "alias.load" is linked. "alias.conf" doesn't load the module. – HUB Apr 13 '11 at 8:03
the only line in alias.load is: LoadModule alias_module /usr/lib/apache2/modules/ Given it works if the Alias is put in the alias.conf, i guess the mod_alias is already loaded. – 0x7c00 Apr 13 '11 at 8:05
It's OK. And does it have a link in enabled directory? – HUB Apr 13 '11 at 8:06
yep :( /****for post length limit***/ – 0x7c00 Apr 13 '11 at 8:08
BTW, I use apache2ctl -l, there's no mod_alias.c listed, weird.

Then that is your problem. If mod_alias is not installed, your alias directive will fail. Have that setup & installed & all should work as expected.

share|improve this answer
The -l option only lists modules that were compiled into Apache. Modules can still be loaded separately. You can list these with the -M option. – Ladadadada Nov 9 '13 at 18:32
Indeed, but if that is the case, the issue of it still not being loaded is in question since that alias directive clearly should work. – JakeGould Nov 9 '13 at 18:43

The folder /etc/apache2/mods-available/ shows available modules, not installed/enabled ones. this means mod_alias is NOT enabled on your machine.

maybe there is a folder like mods-enabled. create with that folder a link to the file /etc/apache2/mods-available/alias.conf. after that reload/restart the webserver.

next is wrong (see comments): apache2ctl -l should show the module.

run "httpd -M" to see the current loaded modules -> httpd command reference

maybe this command doesnt work on your os. every distribution is a bit different. on gentoo use: "apache2ctl modules"

share|improve this answer
there is alias.conf in mod-enabled, and it's a softlink to mod-available. but apache2ctl -l still didn't show. most of the web's tutorial about alias(and other module load configure) is too old (didn't have the split configuration file layout mentioned) – 0x7c00 Apr 13 '11 at 7:56
Your answer seems to be reasonable. But when I run apache2ctl -l, I get: root@host:~# apache2ctl -l Compiled in modules: So this shows only "compiled in" modules And of course, "alias.load" also requres linking.(on Debian system) – HUB Apr 13 '11 at 7:58
you are right, thanks – Bernd Ott Apr 13 '11 at 11:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.