Home  >  Article  >  Backend Development  >  PHP mobile phone cannot jump to domain name

PHP mobile phone cannot jump to domain name

angryTom
angryTomOriginal
2019-11-04 17:29:152926browse

PHP mobile phone cannot jump to domain name

php mobile phone cannot jump to the domain name

Sometimes you encounter the problem that the header Location cannot be redirected on the mobile phone , below we use js instead of header location to implement domain name jump.

header("Location:http://www.php.cn");

was changed to

header('HTTP/1.1 301 Moved Permanently');
header("Content-type:text/html;charset=utf-8");

echo "<script>";
echo "location.href=&#39;http://www.php.cn&#39;";
echo "</script>";

header() for sending native HTTP headers.

header() must be called before any actual output, whether it is ordinary HTML tags, empty lines, or spaces in file or PHP output. This is a common mistake. When accessing functions in other files through include, require, or other functions, if there are spaces or blank lines before header() is called. The same problem exists with separate PHP/HTML files.

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of PHP mobile phone cannot jump to domain name. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn