在 win2003 iis环境下安装了 wordpress 结果伪静态没法用 上网查了一下 有些免费的伪静态规则虽然可以用,但是功能都残缺不全,

最后发现一个简单的替代解决方案  建议一个 php文件 将以下代码写入

<?php
// This is the default file for the site. Usually index.php
$default = ‘index.php’;

// The name of this file.
// Set this value for the URL in Custom Error Properties of your website in IIS.
// Goto: IIS Manager > Websites > [Site Name] > Properties > Custom Errors >
// 404 & 404;2 & 404;3 > URL (Requires a ‘/’ prefix in IIS).
$thisfile = ‘404-handler.php’;

$_SERVER[‘ORIG_PATH_TRANSLATED’] = str_replace($thisfile, $default, $_SERVER[‘ORIG_PATH_TRANSLATED’]);
$_SERVER[‘SCRIPT_FILENAME’] = str_replace($thisfile, $default, $_SERVER[‘SCRIPT_FILENAME’]);
$_SERVER[‘ORIG_PATH_INFO’] = str_replace($thisfile, $default, $_SERVER[‘ORIG_PATH_INFO’]);
$_SERVER[‘SCRIPT_NAME’] = str_replace($thisfile, $default, $_SERVER[‘SCRIPT_NAME’]);
$_SERVER[‘PHP_SELF’] = str_replace($thisfile, $default, $_SERVER[‘PHP_SELF’]);
$_SERVER[‘PATH_INFO’] = false;

$qs =& $_SERVER[‘QUERY_STRING’];
$ru =& $_SERVER[‘REQUEST_URI’];
$pos = strrpos($qs, ‘://’);
$pos = strpos($qs, ‘/’, $pos + 4);
$_SERVER[‘URL’] = $ru = substr($qs, $pos);
$qs = trim(stristr($ru, ‘?’), ‘?’);

// Required for WordPress 2.8+
$_SERVER[‘HTTP_X_ORIGINAL_URL’] = $ru;

// Fix GET vars
foreach ( $_GET as $var => $val ) {
  if ( substr($var, 0, 3) == ‘404’) {
    if ( strstr($var, ‘?’) ) {
      $newvar = substr($var, strpos($var, ‘?’) + 1);
      $_GET[$newvar] = $val;
    }
    unset($_GET[$var]);
  }
  break;
}
include($default);
?>

然后命名为 wp-404.php 然后用这个文件替代你的 404错误页面 即可实现伪静态功能

有朋友说定位404错误页面来实现伪静态,对seo并不友好,经过我实验 到目前为止并不影响google收录

大家如果不喜欢这个方案,就只能升级你的iis到 7.0版本 iis 7.0 可以直接实现wordpress的伪静态功能

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。