PHP Redirect Same Address Different Port
问题 Right now I have this: header("Refresh: 0; url=http://192.168.100.100:10500/redirect2.php"); How can I do the same redirect but without writing address, only port? Both files are in the same folder on the same server. The thing is that I don't know the address that will be used to access this server (private or public). 回答1: Use the superglobal $_SERVER array, Location header and exit; $port = '10500'; header('Location: ' . ($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'