WordPress How to Set 301 redirect

Source: Internet
Author: User
Keywords What WordPress?

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

about why the site to do 301 Redirect, the previous article has been mentioned several times, today, especially to introduce how WordPress set 301 redirect. And according to their own web site space server operating system is different, you have to use a different way to set.

Wordpres How to implement 301 redirection under Windows platform, there are two solutions to choose from:

First, the use of WordPress plug-in function to achieve 301 redirect

The use of WordPress named "Dean's Permalinks Migration" plug-in is very good for me to solve the 301 redirect problem, the use of the method is very simple. It is highly recommended that some beginners use it. The specific steps are as follows:

① download → upload to wp-content\plugins directory → to WordPress background activation;

② Set →permalinksmigration→ Enter the original permanent link form (my is/%category%/%postname%.html), save;

③ set → permanent link → select permanent link form (mine is/archives/%post_id%);

④ in order to ensure that the classification, tag (tag) URL unchanged, in the classification based on the/category, in the basis of the label to fill in the/tag. "This option"

After we have set up several steps above, Googlebot will be able to quickly identify 301 redirects and index the updated URLs. Of course, Googlebot indexing also takes time, bloggers can notify Googlebot by Sitemap.xml.

Second, use the program to achieve 301 redirect

This method is not suitable for beginners to use, because the things involved a little more, the specific operation is as follows:

Log in to the background of the Web site, or use FTP or Control Panel to locate the header.php file, and then add the following red code after <?php:

if (Strtolower ($_server[' server_name '))!= ' ***.com ')
{
$URIRedirect =$_server[' Request_uri '];
if (Strtolower ($URIRedirect) = = "/index.php")
{
$URIRedirect = "/";
}
Header (' http/1.1 moved Permanently ');
Header (' location:http://***.com '. $URIRedirect);
Exit ();
}

How do I achieve 301 redirection in Linux host State?

and Linux server host, relatively simpler, if you are using a Linux host, then set up a fixed connection, the WordPress background will be reflected add the following blue function to the. htaccess file.


<ifmodule mod_rewrite.c>
Rewriteengine on
Rewritebase/
Rewriterule ^index\.php$–[l]
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule. /index.php [L]
</IfModule>

Add the above code will be able to achieve the site's 301 redirect, the Code is as follows (after the redirected URL, remember to modify your own URL):

Rewriteengine on

Rewritecond%{http_host} ^www.***.com [NC]

Rewriterule ^ (. *) $ http://***.com/$1 [l,r=301]

Finally, we upload the. htaccess file to the root directory of the site, you need to pay attention to the problem is. htaccess file in the local need to be modified to TXT format, uploaded to the root directory after renaming to. htaccess is OK.

This article from http://www.45fan.com, reprint should indicate the source!

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.