很多人在使用WordPress时,考虑到自带的固定链接含有动态参数或者是链接较长,都不利于搜索引擎抓取,使得对自带的链接不满意。因此很多站长想要自定义wordpress链接,小编则给大家介绍如何自定义wordpress链接。
WordPress自带的固定链接有5种:
1、朴素:http://域名/?p=123
2、日期和名称型:http://域名/index.php/2016/06/09/sample-post/
3、月份和名称型:http://域名/2016/06/sample-post/
4、数字型:http://域名/index.php/archives/123
5、文章名:http://域名/index.php/sample-post/
当然,还有一种自定义结构的,这个就需要我们自己去进行设置了,可是很多人又不会设置。
先来看一下都有哪些自定义的路径可以设置吧!
第一:/%year%/%monthnum%/%day%/%postname%/
注:设置以后的路径为:http://域名/年/月/日/文章名/
第二:/%year%/%monthnum%/%postname%/
注:设置以后的路径为:http://域名/年/月/文章名/
第三:/%year%/%monthnum%/%day%/%postname%.html
注:设置以后的路径为:http://域名/年/月/日/文章名.html
第四:/%year%/%monthnum%/%postname%.html
注:设置以后的路径为:http://域名/年/月/文章名.html
第五:/%category%/%postname%.html
注:设置以后的路径为:http://域名/分类/文章名.html
第六:/%postname%.html
注:设置以后的路径为:http://域名/文章名.html
第七:/%post_id%.html
注:设置以后的路径为:http://域名/文章ID.html
参数说明:
%year%:代表的是文章发布当年
%monthnum%:代表的是文章发布当月
%day%:代表的是文章发布当天
%postname%:代表的是文章名,必须将文章链接的中文文章名改为英文,建议使用拼音
%post_id%:代表的是文章的ID
%category%:代表的是文章的分类,子分类会处理成“分类/子分类”这种形式
以上只罗列了7种路径,大家也可以根据按照说明进行自由的设置URL,如果设置后不能正常访问或显示404,这是因为我们的空间中还没有伪静态股则文件.htaccess,我们需要将一下代码放入.htaccess文件中,然后上传到网站根目录。