WordPress for Sae achieves 301 redirection after binding an independent domain name

Source: Internet
Author: User

After using the second-level domain name of sinaapp for a long time, the children's shoes using WordPress for Sae finally completed the Record Filing and can bind the domain name. At this time, we found that the original second-level domain name of sinaapp can also be used, this will affect the indexing of independent domain names by the search engine. Therefore, it is necessary to redirect the second-level domain name of sinaapp to the new domain name by 301.

Find the file wp-blog-header.php In the WordPress root directory, and then in the <? PHP?> Insert the following code where appropriate

If (strtolower ($ _ server ['server _ name'])! = 'Z .pekdo.com ')
{
$ Uriredirect = $ _ server ['request _ URI '];
If (strtolower ($ uriredirect) = "/index. php ")
{
$ Uriredirect = "/";
}
Header ('HTTP/1.1 301 moved permanently ');
Header ('location: http://z.pekdo.com '. $ uriredirect );
Exit ();
}
This is a non-Origin
Z.pekdo.com, 301 redirection
Z.pekdo.com. If you only want to redirect the second-level domain name of sinaapp, you can change the first sentence to the following:
If (strtolower ($ _ server ['server _ name']) = 'cailman .sinaapp.com ')

After modification, you can verify at this URL: http://tool.chinaz.com/pagestatus/

Enter the domain name before the redirection and the target domain name after the redirection, and test if the status code 301 and Status Code 200 are returned respectively.

Method 2 of the 301 redirection rule of Sina cloud (SAE:

301 redirection rules of Sina cloud (SAE)

After an independent domain name is bound to an sae application, the original second-level domain name and third-level version links can still be accessed normally. A little understanding of Seo will be clear, this will make the search engine think that it is a duplicate page, is not conducive to the ranking, and will cause questions to the white user. In addition, you also need to redirect the root domain name jevon.cn to www.jevon.cn. I couldn't find the results online for a long time. Now I want to share with you how to perform the 301 jump under Sae.

You only need to add two rules to config. yaml:

- rewrite: if(in_header["host"] ~ "wwwsm.sinaapp.com" && path ~ "^(.*)$") goto "http://z.pekdo.com$1 [L,QSA,R=301]"- rewrite: if(in_header["host"] ~ "^pekdo.com" && path ~ "^(.*)$") goto "http://z.pekdo.com$1 [L,QSA,R=301]"

301 redirection rules of Sina cloud (SAE)
Change wwwsm.sinaapp.com to your own SAE second-level domain name, z.pekdo.com to your primary domain name (the domain name you want to use), and pekdo.com to your root domain name.

301 redirection rules of Sina cloud (SAE)

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.