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

We recently setup SVN for our web development. We'd like to be able to browse different branches/tags/trunk based on the URL you input on our dev server. So, for example, would take you to the index page for the myapp project in the trunk. We have this working fine.

My problem is that we have absolute URLs within the apps that point to, say, "/contact.php". This of course would need to be rewritten to "/trunk/myapp/contact.php". My first thought was to use .htaccess and look at the referrer page, which would let you know what part of the repository you should grab from (ie trunk, branches, etc). For example, if the referrer was "", we'd know to serve up the page from the "rc-1" tag of the "myapp" project. So, I came up with this to put in my .htaccess in the root directory:

RewriteCond %{HTTP_REFERER} /(trunk|branches|tags)/([^/]*)/.*$
RewriteRule ^(.*)$ /%1/%2/$1 [QSA,L,R]

This worked fine until I realized that I couldn't redirect AND maintain POST data. After doing some research, I realized I should probably use mod_proxy. When I change the above code to

RewriteCond %{HTTP_REFERER} /(trunk|branches|tags)/([^/]*)/.*$
RewriteRule ^(.*)$ /%1/%2/$1 [QSA,P]

the posting works, but obviously the URLs don't get rewritten. Is it possible to accomplish both? I'm aware of mod_proxy_html, but I'd prefer to not physically rewrite the URLs in the source.

share|improve this question
Why not change the URLs to relative paths i.e. contact.php? – 84104 Oct 16 '13 at 17:06
Honestly, I probably could change most of the links/sources/actions to use relative paths, and I may just do that. For the time being, though, I'm still interested in seeing whether or not there is a solution for proxying with URL rewrites. – wldrumstcs Oct 16 '13 at 17:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.