Home  >  Article  >  Topics  >  How to do php301 redirect

How to do php301 redirect

(*-*)浩
(*-*)浩Original
2019-05-23 10:26:074171browse

Method to implement php301 redirection: 1. Get the domain name of the current page; 2. Determine the request part after the address; 3. Determine whether the current domain name contains www; 4. If it does not contain www, use header( ) function issues a 301 redirect jump header, and then jumps to the URL with www.

How to do php301 redirect

Friends who do SEO know that after the website is completed, in order to prevent search engines from giving wrong rankings (with www and without www), usually It is a good habit to 301 redirect the domain name without www to the one with www. However, many virtual hosts used by novice friends do not support 301. At this time, we can use code to do 301 redirection. Below we will analyze the 301 redirection jump code of PHP in detail. (//Followed by php comments)

d221a3d7426375c47c9fedc73c03dae7

The above are php code-style 301 redirect jumps. You can put these codes at the head of the page, or you can make the code into a separate php file (such as 301 .php) then call it at the head of the page, the external calling code is:

<?phpinclude("301.php"); ?>。

The above is the detailed content of How to do php301 redirect. 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