Method: 1. Use "header('HTTP/1.1 301 Moved Permanently'); header('Location:URL address');" statement to jump; 2. Use "header('Location:URL' ,true,301)" statement jump.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php implements 301 reload Directional jump
After searching around the Internet, it was all done using
header('HTTP/1.1 301 Moved Permanently');
and then combined with
header('Location: //m.sbmmt.com');
.
I always feel like I can’t finish one sentence, and besides, HTTP/2
has been out for a long time, and I still wrote HTTP/1.1
to watch. It doesn’t feel good. Of course, it’s okay to write HTTP/2
or HTTP/1.0
, but no matter what you write, there is always a feeling of unclear expression (for example, HTTP/ 1.1
is HTTP/2
during actual access - when accessing, it is still HTTP/2
when it should be HTTP/2
. There will be no problem and no confusion. ChangeHTTP/1.1
)
Go to php.net and search again, and find that the Header can be used like this
header ( string $header [, bool $replace = TRUE [, int $http_response_code ]] )
This is easy to handle, in one sentence
header('Location: //m.sbmmt.com', true, 301);
It’s done, hahahahahahaha
One more thing, if you want to adapt HTTPS/HTTP
, this is enough:
header('Location: //m.sbmmt.com', true, 301);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to implement 301 redirect jump in php. For more information, please follow other related articles on the PHP Chinese website!