wordpress 文章网站如何设置伪静态(实测可行)
wordpress网站设置伪静态有利于网站优化,并且有利于搜索引擎爬虫访问,提高网站文章收录的速度。下面我来分享一下wordpress站点伪静态设置的方法:
首先登陆你的wordpress网站后台,默认后台路径为:www.域名.com./wp-admin
登陆到wordpress后台,点击左侧的设置——固定链接
选择“自定义结构”,输入伪静态规则代码。这里提供了2种方式供你参考:
/%post_id%.html
IIS对应伪静态规则
<?xml version="1.0" ?>
<rules>
<rule name="WordPress: http://180.76.242.203_rewrite" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
</conditions>
<action type="Rewrite" url="index.php"/>
</rule>
</rules>
/%postname%.html
/%category%/%post_id%.html
WordPress主题中页面也可以支持伪静态 (实测可行)
我们在wordpress主题开发和使用过程中,经常为了SEO优化,会设置主题链接的伪静态,设置方法很简单,大家也都知道,就是通过后台设置-固定连接来设置就可以了。但是可能很多朋友也发现了,设置好伪静态后,文章页都实现了伪静态,但是页面依然没有。其实如果让页面也支持伪静态也是很简单的,只需要在你的 functions.php 文件中加入以下代码就可以了。
例如(主题:twentyten)
/wp-content/themes/twentyten/functions.php
//页面链接添加HTML后缀
function html_page_permalink() {
global $wp_rewrite;
if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
$wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
}
}
add_action('init', 'html_page_permalink', -1);
然后在后台的固定链接中重新保存一下,看一下xxx是不是变成xxx.html啦!