This article mainly introduces the method of PHP forcing users to redirect to the www domain name, which can simulate the function of 301 redirection and output links when head redirection is not possible. The example in this article describes how PHP forces users to switch to the www domain name. Share it with everyone for your reference.
The specific analysis is as follows:
Sometimes the www domain name and non-www domain name of the website can access the website, but this is not conducive to the inclusion of search engines and will disperse the weight of the web page, so we hope that users will visit Non-www domain names are permanently redirected to www domain names through 301. For example, when users visit php.cn, they will be redirected directly to www.php.cn. This PHP code takes into account the situation that cannot be redirected through head, and will output the link on the page, so that User clicks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
Related recommendations:
##In-depth analysis of php redirection (very useful)
php Several implementation methods of jumping page Example code
php Jump function, and Get the URL address of the current page
The above is the detailed content of php forces users to redirect to www domain name. For more information, please follow other related articles on the PHP Chinese website!