Handling multiple hostnames on a single server

JeffSilver

Joined: 2003-11-11
Posts: 1
Posted: Tue, 2003-11-11 17:38

My web server sits behind an ADSL router/firewall, which means it has 2 hostnames; one for people accessing it from outside and one for local access on my LAN. This gave me a problem, as all the links (e.g. 'login') referred to the hostname set in $gallery->app->photoAlbumURL and $gallery->app->albumDirURL in config.php

This doesn't work in my set-up because the local hostname doesn't work from outside and the outside hostname doesn't work from inside.

I found two ways to fix this by changing the 2 variables mentioned. One way is to use $_SERVER["SERVER_NAME"] instead of a hard-coded hostname.

$gallery->app->photoAlbumURL = "http://" . $_SERVER["SERVER_NAME"] . "/gallery";
$gallery->app->albumDirURL = "http://" . $_SERVER["SERVER_NAME"] . "/albums";

The other (simpler) way is not to have a hostname in these variables at all.

$gallery->app->photoAlbumURL = "/gallery";
$gallery->app->albumDirURL = "/albums";

Now all the links use the same hostname as the original request :P

IMHO there's no reason to have had the hostname in these variables; but there might be a reason I'm unaware of.

 
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13451
Posted: Tue, 2003-11-11 18:02

Check FAQ Gallery:c.22

Basicaly the reasoning behind using absolute URL's is that that when we supported both it confused a lot of users. :)