- 新建一个404.txt文档,将以下代码复制进去:
 
- header(“HTTP/1.1 200 OK”);
 - $ori_qs = $_SERVER[‘QUERY_STRING‘];
 - $pattern = ‘/[^;]+;[^:]+://[^/]+(/[^?]*)(?:?(.*))?/i’;
 - preg_match($pattern, $ori_qs, $matches);
 - $_SERVER[‘PATH_INFO‘] = $matches[1] . ‘?’ . $matches[2];
 - $_SERVER[‘REQUEST_URI‘] = $_SERVER[‘PATH_INFO‘];
 - $query_args = explode(‘&’, $matches[2]);
 - unset($_GET);
 - foreach ($query_args as $arg)
 - {
 - $the_arg = explode(‘=’, $arg);
 - $_GET[$the_arg[0]] = $the_arg[1];
 - }
 - include(‘index.php’);
 - ?>
 
复制进去后,点击另存为,保存为404.php.
- 然后进入WP后台,【设置】–【固定连接】里面,先把固定连接选择自定义,设置成/%post_id%.html。
 - 上传下面的404.php页面到网站根目录下,然后在虚拟主机控制面板里面修改404跳转页面为刚才上传的404.php,这样就可以实现伪静态了