WordPress 本身只需要一条服务器重写规则就能让固定链接正常功能,这条规则就是把所有不存在的文件请求指向 index.php,然后它再通过 PHP 匹配请求的网址,得出最终的请求结果,注入到主循环之中。
这样做的好处就是兼容性强,而且利于插件扩展,我们可以利用相关的 API 来添加自己的重写规则。
在开发类似类似功能的时候,如果出现比如不能正常匹配链接的错误比较难排查,这里可以使用 Rewrite Rules Inspector 插件。

在启用之后进入后台的“工具”→“Rewrite Rules”就能查看到目前所有的重写规则,方便调试。
在后台插件安装界面搜索 Rewrite Rules Inspector 即可在线安装,或者在这里下载 Rewrite Rules Inspector
来源:
https://www.wpdaxue.com/rewrite-rules-inspector.html
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32620.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57