|
最近把网站文章整顿了一番,将所有文章都伪静态了一番。文章统一增加html后缀,并且分类去掉了category,页面增加了html。
1,所有所有分类目录去掉category,安装WP No Category Base插件既可以实现了
在插件后台直接搜索这个wordpress插件就可以实现了,
以前的haitaoseo.com/category/haowen 变成了 haitaoseo.com/haowen/
(分类目录后面增加/有助于百度收录和排名)
2,所有的文章增加html实现伪静态并且自动301跳转
WP固定链接迁移设置页面设置下旧的固定链接结构"/%post_id%"
在"固态链接"页面设置">>自定义结构 /%post_id%.html"
3,在页面后面增加.html
- // 页面链接添加html后缀
- add_action('init', 'html_page_permalink', -1);
- function html_page_permalink() {
- global $wp_rewrite;
- if ( !strpos($wp_rewrite->get_page_permastruct(), '.html')){
- $wp_rewrite->page_structure = $wp_rewrite->page_structure . '.html';
- }}
添加后,需要到固定链接设置页面,重新保存, 否则出现404页面。
设置后以前的没带html页面不能访问,这就是一点点副作用
来源:朱海涛自媒体(微信/QQ号:81433982,公众号zhuhaitao51),原创文章如转载,请注明本文链接:http://www.haitaoseo.com/14713.html |