之前使用Wordpress,使用的是404頁面,來實現rewrite。
但Typecho在後臺開啓rewrite時,會直接告訴我無法開啓,請檢查服務器配置。這樣就連404的方法都不行了。
請問,我這種情況,要如何實現靜態連接?
以下,是WP所使用的404頁面代碼:
代码: 全选
<?php
/* For Wordpress Permalink */
// 404 parameter pattern
$ori_qs = $_SERVER['QUERY_STRING'];
$pattern = '/[^;]+;[^:]+://[^/]+(/[^?]*)(?:?(.*))?/i';
preg_match($pattern, $ori_qs, $matches);
// Request path
$ori_path = $matches[1] . (strlen($matches[2]) > 0 ? '?' . $matches[2] : '');
$_SERVER['PATH_INFO'] = iconv('GBK', 'UTF-8', $ori_path); // For Chinese slug on IIS (CHS)
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
// Query parameters
$query_args = explode('&', $matches[2]);
unset($_GET);
foreach ($query_args as $arg)
{
$the_arg = explode('=', $arg);
$_GET[$the_arg[0]] = $the_arg[1];
}
header('HTTP/1.1 200 OK');
include('index.php');
?>