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 a website which is setup with akamai. My domain and subdomains are mapped onto an Akamai IP.

I have written an Apache rewrite which does an internal URL X to another internal URL Y. This rewrite works fine as long as I am testing in my local setup or for those subdomains which are not mapped onto Akamai but directly onto my Public IP.

My suspicion is that while rewriting the request apache is not able to resolve the IP of the app server correctly.

When I add entries to my /etc/hosts file pointing the domain/subdomain to my internal IP the rewrites work.

Now, I have a huge list of subdomains and it can grow as well. Is there another way to fix this problem without having to make entries in the /etc/hosts file ?

I would much appreciate your thoughts.

share|improve this question

migrated from stackoverflow.com Feb 13 '12 at 2:21

This question came from our site for professional and enthusiast programmers.

What kind of a rewrite are you doing exactly, can you show an example? – Pekka 웃 Feb 10 '12 at 10:57
This question should be asked on server fault – thenetimp Feb 10 '12 at 11:03
Here is the rewrite rule which I have..RewriteRule ^/(context)/(sub-context)(-)([-a-z0-9A-Z]*)/(.*)$ /$1/$2/$5 [P,L] – nuttyket Feb 10 '12 at 11:45

Yes - use a different DNS server, or re-write the URL to use a hostname which works correctly.

However the net effect is the same as changing the entry in your hosts file. But if you are not sending back a redirect from the rewrite, then you'll get marginally better performance by using the loopback adapter rather than (the address of a) real NIC. So just put it in you hosts file as but more importantly this address should never change.

share|improve this answer

I'm actually quite surprised to hear that the rewrite rule you say you have:

RewriteRule ^/(context)/(sub-context)(-)([-a-z0-9A-Z]*)/(.*)$ /$1/$2/$5 [P,L]

works at all, since according to the documentation it shouldn't:

"^/somepath(.*) /otherpath$1 [P]     doesn't make sense, not supported"

If you want to use the [P] flag, your rewrite target should be a full URL. However, I very much suspect that the [P] flag is, in fact, not what you want, and that removing it might fix the problem.

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.