Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

ServerName geekspeak.dev

And in my hosts file:

127.0.1.1 geekspeak.dev

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

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

Thanks!

Edit

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>
  ServerName geekspeak.dev

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

  ProxyPreserveHost On
  ProxyPass /excluded !
  ProxyPass / http://127.0.0.1:9000/
  ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>

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

share|improve this question

1 Answer 1

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 geekspeak.dev, 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 127.0.0.1:9000. Simply ProxyPass /foo ! to not proxy your application. –  Shi Aug 20 '12 at 20:07

Your Answer

 
discard

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.