-1

this is what i have tried:

header('location: http://".$_SERVER["HTTP_HOST"]."/HTML-CW/Account.html');

i also tried this

$hostDb = $_SERVER["HTTP_HOST"];
header('location: http://"$hostDb"/HTML-CW/Account.html');
Scaramouche
  • 3,188
  • 2
  • 20
  • 46
  • 2
    try `header('location: http://' .$_SERVER["HTTP_HOST"].'/HTML-CW/Account.html');`. Notice the use of single quotes instead of double. You can use either BUT, consistently across the statement. – Scaramouche Mar 30 '20 at 19:03
  • duplicate:https://stackoverflow.com/questions/1408996/best-way-to-get-hostname-with-php – thenish Mar 30 '20 at 19:13
  • Does this answer your question? [Best way to get hostname with php](https://stackoverflow.com/questions/1408996/best-way-to-get-hostname-with-php) – Tom Mar 30 '20 at 20:30

1 Answers1

-1

gethostname — Gets the host name https://www.php.net/manual/en/function.gethostname.php

$_SERVER['SERVER_NAME'] Returns the name of the host server (such as www.google.com)

$_SERVER['HTTP_HOST'] Returns the Host header from the current request

http://www.google.com
HTTP_HOST = www.google.com
SERVER_NAME = google.com

http://172.217.31.206
HTTP_HOST = 172.217.31.206
SERVER_NAME = google.com

SERVER_NAME is determined by server configuration; HTTP_HOST is tied to the request

header('location: http://' . $_SERVER["HTTP_HOST"] . '/HTML-CW/Account.html');

or

header('location: http://' . $_SERVER["SERVER_NAME"] . '/HTML-CW/Account.html');

would solve your problem. See " is converted to '.

Also do echo($_SERVER["SERVER_NAME"]) and echo($_SERVER["HTTP_HOST"]) to see what it is outputting in your environment.

M.D
  • 270
  • 2
  • 11