首页 » ASP代码 » wordpress通用伪静态方法最新规则

wordpress通用伪静态方法最新规则

现在用wp博客的越来越多,设置伪静态对搜索引擎是必须的。其实要使用伪静态并不需要Linux主机,也不需要win主机上安装isapi_rewrite组件,wp已经很强自身就带了,下面介绍这种方法。
一、在网站根目录下创建一个 404.php 的文件,代码见最后。
二、在iis上设置404错误页指向一个URL为 /404.php 。
三、到wp后台设置固定链接为自定义的 /%category%/%post_id%.html

<?php
header("HTTP/1.1 200 OK");
$ori_qs = strtolower($_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');
?>

, , , ,

转发到新浪微博 转发到新浪微博

对不起,这篇文章暂时关闭评论。