TAG终于正常了~够折腾的,GODADDY的WIN主机真麻烦

时间: 2011-08-13 / 分类: 网站制作技术 / 浏览次数: 317,559 views / 0个评论 发表评论

就是这个办法

http://www.phpsun.com/web-hosting/2011/03/wordpress-with-chinese-tag-support-using-godaddy-windows-hosting/

COPY一份办法备用
第一步:新建一个“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”);
?>

第二步:如果主机没有“web.config”就新建一个,要是已经存在就“web.config”文件内添加下面的内容:

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name=”ChineseURL” stopProcessing=”true”>
<match url=”^(tag|category)/(.*)$” />
<action type=”Rewrite” url=”chineseurl.php”/>
</rule>
<rule name=”wordpress” patternSyntax=”Wildcard”>
<match url=”*” />
<conditions>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</conditions>
<action type=”Rewrite” url=”index.php” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

这两个文件都上传到WordPress的安装目录。

注意:
如果WordPress不是装在根目录,则需要更改

<match url=”^(tag|category)/(.*)$” />

<match url=”^安装目录/(tag|category)/(.*)$” />

如果在固定链接设置里把默认的标签前缀和分类目录前缀(tag 和 category)改了,则更改这句里的对应内容即可,如

<match url=”^article/(tag|category)/(.*)$” />

具体效果可以参考本文下方的中文Tag标签,可以正常显示,不会再出现404错误了。

我的站tag路径为/archives/tag
所以这里伪静态要修改为

<match url=”^archives/(tag|category)/(.*)$” />

发表评论

您的昵称 *

您的邮箱 *

您的网站