WordPress Virtual Host Set the technique of fixed link

Source: Internet
Author: User
Tags exit header ini root directory linux

WordPress as a mainstream blog system, get a lot of the owners of the favor. In fact, WordPress is also very conducive to SEO, today to say that WordPress in the fixed link settings and optimization.

There are 5 types of fixed links: default P=id form, date + name form, digital form, and custom structure. You can find that most of the WordPress site is the last form of custom structure used, because this form is conducive to search engine optimization. So how should the custom structure be set?

The general custom structure mainly has the following two kinds: directly set to/%postname%/or is set to/%postname%.html. Where%postname% is the custom URL of the article, which will automatically generate a link to the article title as the URL when writing the article. Of course, Chinese stations generally use plug-ins to translate, or they are edited into the form of pinyin. Personally recommend the form of pinyin, you can put the main words of the content of the article written in Pinyin, so more conducive to ranking.

The above two kinds of custom structure is very good, then should choose which kind of good? According to the author's humble opinion, the choice of/%postname%/structure is better. Why do you say that? To choose the former, the search engine actually treats your article as the homepage of the website subdirectory, and chooses the latter as an HTML document under the root directory. Then, the subdirectory of the first page and the root of the ordinary pages of the high weight? should be the first page of the level two directory, so I recommend the use of the former, that is, such as/%postname%/structure.

Once the fixed link is set up, just click "Update" to be OK. If it is a Linux host, WordPress will automatically generate. htaccess, the equivalent of a fixed link to set up this way, but the Windows host will be a lot of trouble, need webmaster write their own httod.ini, and upload to the root directory. A template is provided here.

[Isapi_rewrite]

Rewriterule/sitemap.xml/sitemap.xml [L]

rewriterule/sitemap.html/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 a text document and save it as a httpd.ini and upload it to the root directory. It should be noted that, because the win host in this aspect of the serious flaw, the above code also has a small loophole, that is, the Web site all files are inaccessible. The solution is also simple, if it is a root directory file, just add rewriterule/filename/file name [L] on the line, and the directory in addition to the template has already appeared, as long as the Add Rewriterule/folder directory/(. *)/folder directory/$1 [L] can be. At this point, WordPress's fixed link settings are finally completed.

So, set up your own permalink, the default? p=id form of the link is still accessible? The answer is yes. Again, Linux host and win host the pros and cons. If it is a Linux host, access to the p= form of the Web page will automatically 301 jump to the alias of the article page (that is, your own set up the link), but the win host will not, resulting in each article page can be accessed with two different links. This is very unfriendly to search engines, so you have to let the short link 301 jump to the alias link. So how do you set it? As long as you find header.php in the template, 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 moved Permanently ');/Send 301 Head

Header (' Location: '. Bloginfo (' url '). ' /'. $name. ' /');

Exit ();

}else if ($_get[' cat ']) {

$id =$_get[' cat '];

$cat =get_category ($id);

$name = $cat->slug;

Header (' http/1.1 moved Permanently ');

Header (' Location: '. Bloginfo (' url '). ' /cat/'. $name. ' /');

Exit ();

}else if ($_get[' tag ']) {

$name =$_get[' tag '];

Header (' http/1.1 moved Permanently ');

Header (' Location: '. Bloginfo (' url '). ' /tag/'. $name. ' /');

Exit ();

}?>

Oh, this is finally done, whether it is a Linux host or win host, are really done a fixed link. This also can be seen, if use WordPress system, use Linux host as far as possible. Above is the Sleep Pillow Net (www.89948.net) Stationmaster's a little experience, welcome to comment and reprint, reprint please indicate link oh, thank you!



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.