Two methods of bluefate:wordpress simple 301 Redirection

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Last night to my blog made a 301 redirect, in fact, a lot of online methods, but I still want to share my own hands-on practice to everyone. Because before I to the blog binding two domain names are: www#bluefate#org This is a new registration, because I usually use the net name is bluefate, accumulated a certain degree of visibility, but the COM domain name has been registered n years ago, so only registered an org domain name, hehe, In fact, the org domain name on the search engine weight is relatively high, but everyone prefers COM bale.

Another domain name is www#vxage#com this domain name registration nearly a year, before it was okay, give him some outside chain, now Yahoo back chain more than 2000, do not believe you can go to see oh, whether it is the domain name age or outside the chain to consider, I think his weight should also be OK, But I want to do not want to take this domain blog, so I gave it to 301 directional.

But the Windows platform of that space, it seems impossible to do 301, unless the space provider to you to fix, but I do not want to do so, many times you said, others are not willing to give you. So I thought about getting started with the program. I use the WordPress blog program, this set of procedures for SEO is still pretty good. I believe that we will encounter such problems, in particular, will not take the WWW domain name to the WWW domain name, because I have also contacted the PHP, so it is more comfortable to do.

1. Relatively simple domain 301 redirect: a directed to B

the following references:


$the _host = $_server[' http_host '];//get the current domain name

if ($the _host!= ' www.bluefate.org ')//Determine if the domain name you are getting is not what you want (that is, the domain name after the orientation)

{

Header ("http/1.1 moved Permanently");/Send 301 Head

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

Exit ();

}

put the above code into the root of the index.php of the first place on the line, the effect is the original domain name all the addresses will be jumped to the new domain name of the first page.

2. Another kind of trouble, but the effect will be better:

He can direct all the links under the original domain name to the address of the new domain name, that is, the domain name change, but the parameter is unchanged. The code is as follows:

the following references:


$the _host = $_server[' http_host '];//get the current domain name

if (Strtolower ($the _host)!= ' www.bluefate.org ')//change the domain name you want

{$URIRedirect =$_server[' Request_uri '];

if (Strtolower ($URIRedirect) = = "/index.php")//judgment is the argument/index.php is displayed AS/

{

$URIRedirect = "/";

}

Header ("http/1.1 moved Permanently");/Send 301 Head

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

Exit ();

}

the above two methods, not only suitable for WordPress program, the general PHP program can be used. Write here in fact my blog 301 has been done, I use the second. One of the following methods, interested can also be studied.

In Linux and support rewrite can be set by. htaccess, the code is as follows:

The following are the referenced contents:

the following references:


# 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, is not very simple ah, in fact, many of these methods online, as long as you understand a little code, it is very simple. Well, hope these can help you, if there is a better way, we can share, learn from each other, thank you. Finally exposed my small station Asia-Pacific Cabinet Network www.ytcg360.com, welcome reprint, Reprint please indicate the source. 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.