网络营销,珠宝电商,生鲜水果电商,网站技术,CSS

Godaddy的windows主机的IIS7下WordPress中文URL地址伪静态

现在百度和google都支持网站的URL地址为中文,同时也方便了各位做站的童鞋对网站URL地址进行中文SEO,所以很多网站、博客的URL都开始采用中文地址。 今天我新弄一个WordPress珠宝博客(爱珠宝)的时候也是这么打算的,但是当我使用web.config做伪静态的时候出现404。于是在网上找了如下文方法来解决。因为我的博客是放在Godaddy的windows主机上,所以用的是web.config做伪静态规则。 下面就说说解决方法: 第一步:新建一个“chineseurl.php”文件,内容如下:

<?php

// IIS Mod-Rewrite
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
}
// IIS Isapi_Rewrite
else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
}
else
{
// Use ORIG_PATH_INFO if there is no PATH_INFO
if ( !isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO']) )
$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];

// Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice)
if ( isset($_SERVER['PATH_INFO']) ) {
if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] )
$_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
else
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
}

// Append the query string if it exists and isn’t null
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?'. $_SERVER['QUERY_STRING'];
}
}

require("index.php");

?>

注:代码来自网络,作者不明。