Localhost header重定向到Localhost /link


localhost header redirects to localhost/link

我在我的pc上设计了一个主页,可以通过localhost/home访问。这里我输入一个网站的名称,它必须带我到该网站。我用过header("Location: url ");功能在我的代码,它采取在网站名称适当。但问题是,我试图打开的任何网站,它带我到"localhost/site",如果我在输入中输入www.google.com,它带我到localhost/www.google.com

是否有任何方法,我可以退出本地主机,并去输入google.com ?或者这是不可能的?

您需要提供完整的绝对URL,包括方案。例子:

header('Location: http://www.google.com');