WordPress修改固定链接html后缀伪静态

在默认情况下,刚安装的WordPress的所有网页,都带“问号”的PHP动态链接,虽然搜索引擎不抵触动态页面,但是静态页面依然是现在网站的主流。

博主使用方法

1.WordPress由于是PHP系统,所以不能完美静态化,只可以实现伪静态化,并且只针对文章,其它页面、存档、日期的页面不可以伪静态化。用wordpress所显示的是动态页面不利于搜索引擎收录,seo貌似都在说静态地址的收录相对要比动态地址好些

在此,给出设置wordpress伪静态的方法,打开wordpress后台找到设置——固定连接。

2.改固定连接,也就是静态地址 /index.php /%post_id%.html 然后保存更改,地址就会变为静态地址了,但是这样还不行,你会发现文章页面都打不开。这是我们只需要将修改文件加到网站根目录即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[ISAPI_Rewrite]

\# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

\# Protect httpd.ini and httpd.parse.errors files

\# from accessing through HTTP

\# Rules to ensure that normal content gets through

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

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

\# For file-based wordpress content (i.e. theme), admin, etc.

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

\# For normal wordpress content, via index.php

RewriteRule ^/$ /index.php [L]

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

我们只需建立空白记事本,将以上代码复制到记事本中,重命名文件为httpd.ini

上传文件至网站根目录即可打开网页(从首页进入文章页)

如果上面这个代码还不行,可以换下面代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[ISAPI_Rewrite]

\# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

\# Protect httpd.ini and httpd.parse.errors files

\# from accessing through HTTP

\# wordpress 伪静态规则

\# For tag(中文标签以及标签翻页的规则)

RewriteRule /tag/(.*)/page/(d+)$ /index.php?tag=$1&paged=$2

RewriteRule /tag/(.+)$ /index.php?tag=$1

\# For category(中文分类以及分类翻页的规则)

RewriteRule /category/(.*)/page/(d+)$ /index.php?category_name=$1&paged=$2

RewriteRule /category/(.*) /index.php?category_name=$1

\# For sitemapxml

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

RewriteRule /sitemap.html /sitemap.html [L]

RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]

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

\# For file-based wordpress content (i.e. theme), admin, etc.

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

\# For normal wordpress content, via index.php

RewriteRule ^/$ /index.php [L]

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

注:该文章转载https://blog.csdn.net/weixin_36215903/article/details/117970570

其他博主教程如下:WordPress固定链接伪静态设置图文教程 - 腾讯云开发者社区-腾讯云 (tencent.com)

插件教程:为wordpress分类、页面和标签页固定链接添加.html后缀 - 腾讯云开发者社区-腾讯云 (tencent.com)