Home >Backend Development >PHP Problem >What does php redirect mean?
In PHP, redirection refers to redirecting network requests to other locations through various methods; redirection can be divided into internal and external. The difference is that when external redirection occurs, the browser address The URL in the column will change.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php redirection
Redirect is to redirect various network requests to other locations through various methods. Divided into internal and external, the difference is that when external redirection occurs, the URL in the browser address bar will change.
Page redirection must have page jump, page jump does not necessarily have page redirection, that is to say, page redirection is really included in page jump, page redirection is page jump sufficient and unnecessary conditions.
When we are building a website, we often encounter situations that require web page redirection:
1. Website adjustment (such as changing the web page directory structure);
2. The web page is moved to a new address;
3. The web page extension is changed (if the application needs to change .php to .Html or .shtml).
In this case, if redirection is not done, the old address in the user's favorites or search engine database will only allow the visiting customer to get a 404 page error message, and the access traffic will be lost in vain; in addition, some registrations Websites with multiple domain names also need to redirect users who visit these domain names to automatically jump to the main site.
Summarize several methods of page jump under PHP
1. Meta tag implementation
Just add the following sentence in the head That’s it, jump to the target page after staying on the current page for 0 seconds
echo '<meta http-equiv="refresh" content="0;url=https://www.baidu.com">';
2. JavaScript implementation
echo '<script>window.location.href = 'https://www.baidu.com';</script>';
3. PHP page redirection implementation
header('Location: https://www.baidu.com');
Use PHP page The redirect jump is a little different from the above two methods in that its http response status code is specified as 3xx. The specific difference involves the HTTP request process, so I won’t go into details here.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What does php redirect mean?. For more information, please follow other related articles on the PHP Chinese website!