Webmasters Stack Exchange is a question and answer site for pro webmasters. 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 these Rewrites, but I would like to have the URL stay the same as what is typed originally, I thought removing the [R] flags would stop it but it hasn't

RewriteCond %{HTTP_HOST} ^examplea\.example\.com$ [NC]
RewriteRule (.*) http://examplea.example.com:32400/web [L]

RewriteCond %{HTTP_HOST} ^exampleb\.example\.com$ [NC]
RewriteRule (.*) http://exampleb.example.com:9091 [L]

Edit: would this work better?

RewriteCond %{HTTP_HOST} ^hello.example.com$ 
RewriteRule ^(/)?$ welcome [L]
share|improve this question
It will always trigger an external redirect if you specify a different port, regardless of whether you explicitly state it is a Redirect or not. However, you can get around this with mod_proxy. See this answer on SO: stackoverflow.com/questions/9308088/… – w3dk Apr 24 '14 at 19:21
I like using mod_proxy. Just use caution to secure your mod_proxy before enabling. Otherwise, it will not take long before the Chinese begin to send many 100K's requests per hour to your site. – closetnoc Apr 24 '14 at 20:15
ahh okay, how do you secure your mod proxy? – user38100 Apr 24 '14 at 21:27

It looks to me like you would are trying to fetch data from a web service that is running on another port and display it using your main web server.

mod_rewrite can be configured to do so. You have to have mod_proxy enabled and use [P] with your rewrite rules. Your directives might look like this:

RewriteEngine  on

RewriteCond %{HTTP_HOST} ^examplea\.example\.com$ [NC]
RewriteRule (.*) http://examplea.example.com:32400/web/$1 [P,L]
ProxyPassReverse / http://examplea.example.com/

RewriteCond %{HTTP_HOST} ^exampleb\.example\.com$ [NC]
RewriteRule (.*) http://exampleb.example.com:9091/$1 [P,L]
ProxyPassReverse / http://exampleb.example.com/
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.