Page 1 of 1

Support for non-standard ports

Posted: Mon Aug 27, 2007 7:28 am
by akpraha
I've got a site that's running on a non-standard port, ie. other than 80 (HTTP) or 443 (HTTPS).  The default generated config.php does not take into account the port from the HTTP request when generating the root_url to be used throughout the system.  I edited config.php by hand to do this, and now it will work for non-standard ports:

Code: Select all

$config['root_url'] = 'http://sfservis.stedar.org';
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on')
{
$config['root_url'] = str_replace('http','https',$config['root_url']);
}

/******************************************************************
Start support for non-standard ports
*******************************************************************/
if (isset($_SERVER['SERVER_PORT']) && ($_SERVER['SERVER_PORT']!='80' && $_SERVER
['SERVER_PORT']!='443'))
{
$config['root_url'] = $config['root_url'] . ":" . $_SERVER['SERVER_PORT'];
}
This also handles cases where apache listens on port 80, but a firewall is allowing NAT access on a different port and translating it to 80.

Re: Support for non-standard ports

Posted: Mon Aug 27, 2007 8:58 am
by Pierre M.
Thank you. I hope your patch will go mainstream.

Pierre M.

Re: Support for non-standard ports

Posted: Mon Aug 27, 2007 10:02 am
by cyberman
Nice solution - many thanks.

Have added it to wiki

http://wiki.cmsmadesimple.org/index.php ... dard_ports