BLUEFATE: two simple 301 redirection methods for Wordpress

Source: Internet
Author: User
Tags wordpress blog

I made a 301 redirection to my blog last night. In fact, there are many methods on the Internet, but I still want to share my own practices with you. Because I previously bound two domain names to my blog: www # bluefate # org, which is newly registered, because I usually use the network name BLUEFATE, which has accumulated a certain degree of popularity, however, the COM domain name was registered N years ago, so only one org domain name was registered, but everyone prefers com.

Another domain name is www # vxage # com, which has been registered for nearly a year. When I was okay, I made some external links for him. Now, there are more than two thousand anti-chain Yahoo, if you don't believe it, you can check it out. Whether it's the age of the domain name or the external chain, I think his weight should be okay, but I don't want to use this domain name as a blog, so it is directed to 301.

However, for the space on the windows platform, it seems that there is no way to do 301, unless it is done by a space provider, but I don't want to do that. Many times you said, others are not willing to do it for you. So I want to start with the program. I am using the wordpress blog program. This program is quite good for SEO. I believe that you will also encounter such problems at ordinary times, especially targeting www-free domain names, because I have been familiar with PHP before, so it is quite easy to do it.

1. Relatively simple 301 redirection of domain names: to redirect A to B Branch

Reference content is as follows:

$ The_host = $ _ SERVER [HTTP_HOST]; // get the current domain name

If ($ the_host! = Www.bluefate.org) // determines whether the obtained domain name is what you want (that is, the domain name after targeting)

{

Header ("HTTP/1.1 301 Moved Permanently"); // issue the 301 header

Header ("Location: http://www.bluefate.org"); // jump to the domain name you want

Exit ();

}

Put the above Code into the index. php The first step is to move all the addresses under the original domain name to the home page of the new domain name.

2. The other one is more troublesome, but the effect will be better:

He can direct all links under the original domain name to the corresponding address of the new domain name, that is, the domain name changes, but the parameters remain unchanged. The Code is as follows:

Reference content is as follows:

$ The_host = $ _ SERVER [HTTP_HOST]; // get the current domain name

If (strtolower ($ the_host )! = Www.bluefate.org) // change the domain name here to what you want

{$ URIRedirect = $ _ SERVER [REQUEST_URI]; // obtain the parameters of the domain name.

If (strtolower ($ URIRedirect) = "/index. php") // if the parameter is/index. php, it is displayed/

{

$ URIRedirect = "/";

}

Header ("HTTP/1.1 301 Moved Permanently"); // issue the 301 header

Header ("Location: http://www.bluefate.org". $ URIRedirect); // jump to the address format you want

Exit ();

}

The above two methods are not only suitable for wordpress programs, but can be used by PHP programs. In fact, 301 of my blog has been completed. I use the second one. The following method can be studied if you are interested.

In linux and supports rewrite, you can set it through. htaccess. The Code is as follows:

Reference content is as follows:

Reference content is as follows:

# BEGIN WordPress

<IfModule mod_rewrite.c>

Options + FollowSymLinks

RewriteEngine on

Rewritecond % {http_host} ^ www.a.com [nc]

Rewriterule ^ (. *) $ http://www. B .com/#1 [L, R = 301]

</IfModule>

# END

Haha, isn't it very simple? In fact, there are many methods on the Internet, as long as you know a little code, it is very simple. Well, I hope this will help you. If there is a better way, you can share and learn from each other. Thank you. At last, I exposed my small site www.ytcg360.com. You are welcome to reprint it. Please indicate the source for reprinting. Thank you.

Related Article

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.