Forum: 

default index.php hyperlinks broken when running on non-default port

I have a turnkeylinux LAMP stack, and installed Jenkins on it.  I moved Jenkins to port 80, and changed apache to port 8080.  After doing so, the hyperlinks in the index.php page didn't work, because they showed up as https://server:8080:12320, instead of https://server:12320

The fix was super easy, just added a regex to strip off the existing colon and port number.

old

<a href="https://<?php print
$_SERVER{'HTTP_HOST'}; ?>:12321"><img
src="images/webmin.png"/>Webmin</a>

new

<a href="https://<?php print
preg_replace('/:\d+$/', '', $_SERVER{'HTTP_HOST'}); ?>:12321"><img
src="images/webmin.png"/>Webmin</a>

Post new comment