微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

iis下wordpress程序的伪静态规则列表

1.新建一个“chineseurl.PHP文件:在里面写入以下代码上传wordpress安装目录。

<?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");
?>

第二步:

 1.新建一个文件命名为:web.config,在里面写入以下规则(该规则适用wordpress后台标签前缀和分类目录都未更改。):

<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
   <system.webServer>
     <rewrite>
       <rules>
         <rule name="ChineseURL" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
             <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
             <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
           </conditions>
          <action type="Rewrite" url="chineseurl.PHP"/>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

 2.认的标签前缀和分类目录前缀有更改的情况下,规则如下

<?xml version="1.0" encoding="UTF-8"?>
   <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>

 注意:"<match url=”^(tag|category)/(.*)$" />”需要根据实际目录来修改,假如安装在blog目录,则应改为“<match url=”^blog/(tag|category)/(.*)$” />” 标签前缀和分类目录名称根据实际目录修改

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐