Tips for setting fixed links for Wordpress Virtual Hosts

Source: Internet
Author: User

Wordpress, as a mainstream Blog system, is favored by many webmasters. In fact, wordpress is also very beneficial to seo. Today we will talk about fixed link settings and Optimization in wordpress.

Fixed links generally have five forms: default? P = id, date + name, number, and custom structure. You can find that most wordpress websites use the last custom structure, because this form is conducive to search engine optimization. So how should we set the custom structure?

Generally, the custom structure can be directly set to/% postname %/or to/Your postname.html. html. Here, % postname % is the custom URL of the article, which will automatically generate a link with the article title as the URL when writing the article. Of course, Chinese websites generally use plug-ins for translation, or edit themselves into pinyin forms. I personally recommend the pinyin format. I can use Pinyin to write the main Keywords of the article content, which is more conducive to ranking.

The two custom structures mentioned above are all good. Which one should I choose? In my opinion, the/% postname %/structure is better. Why? Select the former. In fact, the search engine regards your article as the homepage of the website subdirectory, and the latter is an html document under the root directory. Which of the following has a high weight for the homepage of a subdirectory and the common page of the root directory? It should be the homepage of the level-2 directory. Therefore, the former is recommended, that is, the structure like/% postname %.

After the fixed link is set, click "Update. If it is a linux host, wordpress will automatically generate. htaccess, which is equivalent to setting up a fixed link. However, it takes a lot of trouble for a windows host, and the webmaster needs to write it by himself. ini and upload it to the root directory. A template is provided here.

[ISAPI_Rewrite]

RewriteRule/sitemap. xml/sitemap. xml [L]

RewriteRule/sitemap.html [L]

RewriteRule/favicon. ico/favicon. ico [L]

RewriteRule/wap (. *)/wap $1 [L]

RewriteRule/content/uploads/(. *)/content/uploads/$1 [L]

RewriteRule/wp-(. *)/wp-$1 [L]

RewriteRule ^/$/index. php [L]

RewriteRule/(. *)/index. php/$1 [L]

Just paste the above Code into the text document, save it as httpd. ini, and upload it to the root directory. It should be noted that, due to the serious defect of the win host in this regard, the above Code also has a small vulnerability, that is, all files on the website cannot be accessed. The solution is also very simple. If it is a root directory file, you only need to add RewriteRule/file name [L]. In addition to the existing directory in the template, just add the RewriteRule/folder directory /(. *)/folder directory/$1 [L. So far, wordpress's fixed link settings are complete.

So, set your own fixed link, default? Can a link in the form of p = id still be accessible? The answer is yes. Let's talk about the advantages and disadvantages of linux host and Windows host. If it is a linux host, access? A webpage in the form of p = will automatically jump to the post page of the alias (that is, the link you set) 301, but won't go to the win host, as a result, each article page can be accessed using two different links. This is unfriendly to search engines, so you must redirect the short link 301 to the alias link. So how to set it? You only need to find the header. php In the template and add the following code to the header.

  

If ($ _ GET ['P'] | $ _ GET ['page _ id']) {

If ($ _ GET ['P']) $ id = $ _ GET ['P'];

If ($ _ GET ['page _ id']) $ id = $ _ GET ['page _ id'];

$ Post = get_post ($ id );

$ Name = $ post-> post_name;

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

Header ('location: '. bloginfo ('url').'/'. $ name .'/');

Exit ();

} Else if ($ _ GET ['cat']) {

$ Id = $ _ GET ['cat'];

$ Cat = get_category ($ id );

$ Name = $ cat-> slug;

Header ('HTTP/1.1 301 Moved Permanently ');

Header ('location: '. bloginfo ('url').'/cat/'. $ name .'/');

Exit ();

} Else if ($ _ GET ['tag']) {

$ Name = $ _ GET ['tag'];

Header ('HTTP/1.1 301 Moved Permanently ');

Header ('location: '. bloginfo ('url').'/tag/'. $ name .'/');

Exit ();

}?>

Well, this is a success. Both the linux host and the win host are actually fixed links. It can also be seen that if the wordpress system is used, try to use the linux host as much as possible. The above is a bit of experience from the webmaster of sleep pillow Network (www.89948.net). You are welcome to give comments and repost them. Please note the link 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.