Home >Backend Development >PHP Tutorial >php 301 redirect code_PHP tutorial

php 301 redirect code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:54:04935browse

The best way to be friendly to search engines after changing the address of a webpage is to do a 301 redirect. If it is not to temporarily transfer one or some web pages, we all think it is more appropriate to do a 301 redirect.

The best way to be friendly to search engines after changing the address of a webpage is to do a 301 redirect. If it is not to temporarily transfer one or some web pages, we all think it is more appropriate to do a 301 redirect.

The following 301 redirect code is commonly used in PHP tutorials

header( "http/1.1 301 moved permanently" ) ;
header( "location: http://www.bKjia.c0m/" );
?>

301 redirect is a permanent redirect. When a user or a search engine sends a browsing request to our website, the website server will return an http data stream. The data stream header information (header) contains some kind of status code. 301 is a status code that indicates that this webpage has been permanently transferred to another address

Notes, about header function

header(string,replace,http_response_code)

The header() function sends raw http headers to the client.

It is important to realize that the header() function must be called before any actual output is sent (in PHP 4 and above, you can use output caching to solve this problem):

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632350.htmlTechArticleThe best way to be friendly to search engines after changing the address of the webpage is to do a 301 redirect. If it is not temporarily If a certain web page or pages are to be transferred, we all think it is more appropriate to do a 301 redirect...
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