Server Fault is a question and answer site for system and network administrators. 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 an apache2 server that is behind a firewall. The external address is and the internal address is

The server's hostname is 'myhost'. I don't have a DNS entry for the address because it's not live yet. The domain name that will resolve to it is currently in use for the existing site.

I would like the web-dev team to be able to access the site via the address. However, whenever they view the site, all the URLs get the local hostname inserted into them.

So, <a href="index.php?id=9">Link</a> produces a URL of http://myhost/index.php?id=9 However, I would like it to produce a URL of

Apache is installed on Debian Lenny. I'm using the "default" site. I've tried variations of setting the NamedVirtualHost to the IP, ServerName to the IP, UseCanonicalName off, VirualHost, etc... Everything I do produces no change whatsoever. Yes, I'm reloading the config each time.

I've also tried cutting out the firewall, and I get the same result. I've also made a bunch of changes to the /etc/hosts file.

/etc/hosts:       localhost      myhost
share|improve this question
This is a programming question, not a sysadmin one. – womble Dec 1 '09 at 21:03
I beg to differ, considering I'm not doing any programming. – Swoogan Dec 1 '09 at 21:08
how is that ever a programming question? – hop Dec 1 '09 at 22:28
It's a programming question because this is an issue with his content producing system, not apache. However, it could be easily mis-identified as a server issue. – phoebus Dec 1 '09 at 22:42
up vote 2 down vote accepted

Reading more carefully, I think this might be a php issue. Generally, you need to set some sort of 'base URL' in the config for a website, so php knows how to create all of the links ("Over write the urls"). Look for a config.php, or something like that in the root dir of the website.

If you have bad developers, it might be not in a single variable, and all over the place. To find this, or maybe to find it in a single location, use grep -Ri --include='*.php*' 'localhost' *, changing localhost to whatever it is that is currently being overwritten.

Not a Complete Answer:
I am not entirely sure, but I think I remember that binding a virtual host to specific IP, or changing the listen directive requried a total restart, not just a graceful restart or a configuration reload.

share|improve this answer

I can guarantee that the problem isn't apache. You should be looking at whatever is producing your html content... ie. php, etc.

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.