I recently inherited an Apache web server when I accepted a position in a university lab. The job was only supposed to involve being the sys admin for a couple of high performance clusters but now it seems I need to learn a bit about mod_rewrite. The Apache server listens on port and there is a python web server that listens on In our DNS server, subdomainone.example.com points to and subdomaintwo.example.com points to Another python web server used to listen on but that server was folded into the one on and is available at There is a rule in place that used to redirect requests for subdomainthree.example.com to subdomainone.example.com:8010 but I've been asked to amend the rules to make subdomainthree.example.com redirect to subdomaintwo.example.com:8092/subdomainthree. I'm fairly sure it can be done but I've gone through a few regular expression tutorials and have yet to come up with a solution that works.

Here is the old rule for subdomainthree.example.com:

RewriteCond %{HTTP_HOST} ^subdomainthree.example.com [NC]
RewriteRule ^/(.*) http://subdomainone.example.com:8010/$1 [L,R,proxy]

This is my most recent attempt to get it working with the current configuration:

RewriteCond %{HTTP_HOST} ^subdomainthree.example.com/subdomainthree [NC]
RewriteRule ^/docking/(.*) http://subdomaintwo.example.com:8092/subdomainthree/$1 [L,R,proxy]

RewriteCond %{HTTP_HOST} ^subdomainthree.example.com [NC]
RewriteRule ^/(.*) http://subdomaintwo.example.com:8092/subdomainthree [L,R,proxy]

The initial redirect works but, when I try to follow links to any subdirectories from there, I get the same page with a URL that looks like this:


Clicking on the link to the same subdirectory again gives me the same page again with the following URL displayed:


My understanding of regular expressions is pretty poor as I'm sure is evident by this attempt. Could someone help me to understand what is going on here and help me correct it?