Apache: How to auto-expand header to fully-qualified domain name?
SummaryHow can I control automatic-domain-name expansions in the header field via apache/httpd.conf? Without this, I'm forced to insert this in index.php:
if (trim(strtolower($_SERVER['SERVER_NAME'])) == "myserverapp")
{
header("Location: http://myserverapp.mydomain.com/");
exit;
}
I want to instead control this behavior in httpd.conf.
Details
(Aside: are there any other forums that are targeted towards discussing Apache configurations such as these?)
I host a corporate-intranet webserver with multiple applications (phpBB, moodle.org, probably some CMS like cpgnuke, etc).
My users often reference said server without specifying the domain name in the browser. ie, if the server name is myserverapp.mydomain.com, they often just type in "myserverapp" into their web browser because all of our client machines have auto-dns-domain settings of "mydomain.com."
This is mostly ok...except when someone starts saving weblinks/URLs/URIs to these webservers and referencing them to other people (or even on the webserver itself, like in the phpbb discussions) that do not reside on mydomain.com. Then the weblinks break.
To get around this, I stick something like the following lines in the index.php of each server application folder:
if (trim(strtolower($_SERVER['SERVER_NAME'])) == "myserverapp")
{
header("Location: http://myserverapp.mydomain.com/");
exit;
}
This forces an "auto-expansion" of the servername to the fully-qualified the domain name...without the user having to do anything. Thus all the "copy and pasted" web links from the browser field all come out fully-qualified...and thus will not break.

Can I force and control all this behavior exclusively through apache (and specify it in httpd.conf) so that I can remove the above index.php edits? These index.php edits are not as elegant, harder to control, and do not scale as well as the centrally-controlled httpd.conf. Futhermore, the index.php edits do not work when making a reference to http://myserverapp/urlpath because I need it to instead expand to http://myserverapp.mydomain.com/urlpath .
Thanks for any help!
-Matt