31

今天翻出了一个购买后一直闲置的国内php虚拟主机,打算装个wordpress,可惜是个win系统,不支持rewrite,只能寻求其它伪静态的解决办法。

百度后找到这段代码:

<?
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,作为主机默认的404错误页面即可实现伪静态

添加评论