How to set up Apache 2 to serve only subdirectories
Posted
by
Lynden Shields
on Server Fault
See other posts from Server Fault
or by Lynden Shields
Published on 2012-12-04T03:14:33Z
Indexed on
2012/12/04
5:06 UTC
Read the original article
Hit count: 191
apache2
I have 3 sites which need to be hosted on a web server (apache2 from repo running on Ubuntu 12.04). They are each in their own subdirectory within /var/www/
I would like apache to serve files from the relevant directories only if the directory name is given in the URL, but not serve the /var/www/
directory itself.
E.g: http://1.2.3.4/site1/
should work and serve the index from /var/www/site1/index.html
, but http://1.2.3.4/
should not serve anything.
Currently, I can't get the url to point to the directory. Either I can get http://1.2.3.4/
to serve everything within /var/www/
(including /var/www/site2/secretstuff/
), or I can get the root http://1.2.3.4/
to serve one of the subdirectories (/var/www/site1/
). This is unacceptable site 1 needs Indexes enabled but the others must not.
I just want to make site1's config only respond to requests of the form http://1.2.3.4/site1/*
and not handle requests of the form http://1.2.3.4/
I do not have a domain name set up so I can't use subdomains.
© Server Fault or respective owner