title: Add subfolder to URL when passing through specific httpd server
body: <p>I want to run a rails webapp (GitLab) in a subfolder, like <code>http://localhost/gitlab</code>, and I want to use Apache <code>httpd</code> to perform this. Some apache conf for GitLab are available <a href="https://github.com/gitlabhq/gitlab-recipes/blob/master/web-server/apache/gitlab.conf" rel="nofollow">here</a> and they work well when I use them in a simple context.</p>
  
  <p>But now I try to include this conf in a more complicated Apache conf. I have the following Apache HTTPD config: </p>
  
  <p><strong>Front main http serveur:</strong></p>
  
  <pre><code>ServerName localhost
  Listen 80
  ...
  (lot of rules)
  ...
  ProxyPreserveHost On
  ProxyPass /gitlab http://127.0.0.1:8888/
  ProxyPassReverse /gitlab http://127.0.0.1:8888/
  </code></pre>
  
  <p><strong>2nd server</strong>, where I have the apache conf for Gitlab and where I <strong>try</strong> to rewrite URL to add <code>/gitlab/</code> in the URL :</p>
  
  <pre><code>Listen 8888
  ...
  RewriteCond %{REQUEST_URI} !^/gitlab/
  RewriteRule ^(.*)$ /gitlab/$1
  ....
  &lt;VirtualHost *:8888&gt;
    ServerName gitlab
    ServerSignature Off
    ProxyPreserveHost On
  
    &lt;Location /&gt;
      Order deny,allow
      Allow from all
      ProxyPassReverse http://127.0.0.1:3000/
    &lt;/Location&gt;
  
    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:3000%{REQUEST_URI} [P,QSA]
  
    DocumentRoot /opt/gitlab/.../public
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>And finaly I have the GitLab's <code>unicorn</code> http server running at <code>127.0.0.1:3000</code>. </p>
  
  <hr>
  
  <p><strong>The problem :</strong>
  When with a browser I go to <code>localhost:80/gitlab</code> it works: I can access the GitLab homepage. But all html links on this page lead me to <code>localhost:80/somewhere</code> and not to <code>localhost:80/gitlab/somewhere</code>.</p>
  
  <p>So here is my question: how can I (in my 2nd httpd instance, running on <code>8888</code>) <strong>force</strong> the add of <code>/gitlab/</code> in the URL for each query passing though this server ? I tried some <code>RewriteRule</code> in the conf, but they didn't change any URL. </p>
  
  <p>(Also, for some reasons I don't want to use the Rails config <code>relative_url_root: /gitlab</code> param to achieve this: it does not make GitLab run in a subdirectory, it just create a redirection from <code>/</code> to <code>/gitlab/</code>.)</p>