Header () 301 redirection implementation code _ PHP Tutorial

Source: Internet
Author: User
Header () 301 redirection implementation code. Let's take a look at an example, header (location: www.111cn.cn); the above is a simple jump. how do we do this for permanent redirection. As follows. Syntax header (string, replace, http_respo first look at an instance,

Header ('Location: http://www.111cn.cn /');

The above is a simple jump. what should we do for a permanent turn. As follows.


Syntax
Header (string, replace, http_response_code) parameter description
String is required. Specifies the header string to be sent.
Replace is optional. Indicates whether the header replaces the previous header or adds the second header.

The default value is true (replace ). False (multiple headers of the same type are allowed ).

Http_response_code is optional. Forces the http response code to the specified value. (Php Tutorial 4 and later are available)


In other cases, http_response_code is the 301 code to be written, as shown below.


$ Url = "http://www.zhutiai.com ";
Header ("http/1.1 301 moved permanently ");
Header ("location: $ url ");
Exit ();

Note: After php 4.4, this function prevents multiple headers from being sent at a time. This is a protection against header injection attacks.


Cursor, header (location: http://www.111cn.cn/); above is a simple jump, we want to do permanent turn how to do it. As follows. Syntax header (string, replace, http_respo...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.