Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Let's say I have a virtual host with a ServerName directive like so:


And in my hosts file:

Now when I enter in my browser, I'm directed to my application running on localhost. Simple.

But what if instead of, I want to require users to enter to get to my app. Is there an apache directive or some other technique that will allow me to accomplish this?



I tried adding an empty DocumentRoot and an Alias as suggested by Shi, but I had no success. I wonder if the fact that it's acting as a proxy has anything to do with it? I've pasted my virtual host below, maybe someone can see what's wrong with it.

<VirtualHost *:80>

  DocumentRoot /var/www/foo
  Alias /foo /var/www/foo

  ProxyPreserveHost On
  ProxyPass /excluded !
  ProxyPass /
  ProxyPassReverse /

I'm expecting this to reach my app at / but instead it reaches my app at /foo

share|improve this question

My guess is that you use DocumentRoot inside your virtual host pointing to your application.

For "drop-in" installation of applications I suggest you simply use an empty directory as DocumentRoot, or whatever content should be available there, and use Alias to point to your application.

Alias /foo /var/www/web-application
share|improve this answer
I can't get this to work properly. I've updated my question to include the contents of the virtual host. Let me know if anything stands out. Thanks! – Samo Aug 20 '12 at 14:57
@Samo: Having both DocumentRoot and Alias pointing to the same directory looks VERY strange. /excluded is served from, so right now it has to be located in the filesystem at /var/www/foo/excluded. Maybe that's right, maybe not, I do not know. Anyway, you proxy everything, including /foo to Simply ProxyPass /foo ! to not proxy your application. – Shi Aug 20 '12 at 20:07

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.