Hello,
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 192.168.1.93:80 and there is a python web server that listens on 192.168.1.97:8092. In our DNS server, subdomainone.example.com points to 192.168.1.93 and subdomaintwo.example.com points to 192.168.1.97. Another python web server used to listen on 192.168.1.93:8010 but that server was folded into the one on 192.168.1.97:8092 and is available at 192.168.1.97:8092/subdomainthree. 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:
http://subdomainthree.example.com/subdomainthree/subdirectory
Clicking on the link to the same subdirectory again gives me the same page again with the following URL displayed:
http://subdomainthree.example.com/subdomainthree/subdomainthree/subdirectory
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?
Thanks,
Matt