时间:2012-03-29 11:36
实现固定连接伪静态方法
方法一:使用伪静态iis规则
[ISAPI_Rewrite]
CacheClockRate 3600
RepeatLimit 32
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
后台设置固定链接参数后(见上述),拷贝上面代码存为httpd.ini文件,上传到网站根目录后即可
方法二,使用404页面跳转
<?php
header('Status : 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错误页即可。