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 two versions of a very small ruby-on-rails apps running on my web server. One is served externally (production) and one is served only on an intranet URL (staging). So I have two Virtual Hosts setup and they work well.

My goal is to serve up the generated documentation for the code base underneath the domain of the staging server, but just setup a different vhost and docroot and dump all the static HTML files there. I'm unclear how to set this up in httpd.conf.

So, the goal is to have: -> rails app vhost (pointed at /var/www/rails/foo/)

and -> documentation vhost (pointed at /var/www/doc/foo/)

Sorry about the clumsiness of the question; I'm pretty sure this can be done with mod_rewrite but after reading through the docs several times I'm still lost as to how to accomplish this Feat of Strength.

share|improve this question
up vote 1 down vote accepted

You can specify the rewrite rule like it's shown in this example :

   DocumentRoot /www/subdomain/sub2
   ServerName www.sub2.domain.tld
   ServerPath /sub2/
   RewriteEngine On
   RewriteRule ^(/sub2/.*) /www/subdomain$1

Use the ServerPath like you want (doc in your example) and then use RewriteRule to bind the ServerPath to your new location. Don't forget the $1 (matched part).

Don't forget to load mod_rewrite in apache.

share|improve this answer

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.