先保证你用的是IIS自带的URL重写 (其他伪静态工具同理)
----------------------------
cnurl.php 文件
<?php
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
// IIS Mod-Rewrite
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
} else if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
// IIS Isapi_Rewrite
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
} else {
// Use ORIG_PATH_INFO if there is no PATH_INFO
(!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'])) {
($_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME']) ? ($_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']) : ($_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO']);
}
// Append the query string if it exists and isn't null
(isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) && ($_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']);
}
require("index.php");
?>
web.config 文件 注意话题 和搜索
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="已导入的规则 1" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="/?" appendQueryString="false" />
</rule>
<rule name="已导入的规则 3" stopProcessing="true">
<match url="^users/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/users/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 4" stopProcessing="true">
<match url="^favorite/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/favorite/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 5" stopProcessing="true">
<match url="^explore/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/explore/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 6" stopProcessing="true">
<match url="^notifications/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/notifications/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 7" stopProcessing="true">
<match url="^inbox/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/inbox/{R:1}" appendQueryString="false" />
</rule>
<rule name="CNurlyonghu" stopProcessing="true">
<match url="^people/(.*)$" />
<action type="Rewrite" url="cnurl.php" />
</rule>
<rule name="已导入的规则 9" stopProcessing="true">
<match url="^setting/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/setting/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 10" stopProcessing="true">
<match url="^logout/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/logout/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 11" stopProcessing="true">
<match url="^publish/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/publish/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 12" stopProcessing="true">
<match url="^feature/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/feature/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 13" stopProcessing="true">
<match url="^home/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/home/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 14" stopProcessing="true">
<match url="^account/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/account/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 15" stopProcessing="true">
<match url="^login/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/login/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 16" stopProcessing="true">
<match url="^reader/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/reader/{R:1}" appendQueryString="false" />
</rule>
<rule name="CNurl" stopProcessing="true">
<match url="^search/(.*)$" />
<action type="Rewrite" url="cnurl.php" />
</rule>
<rule name="已导入的规则 18" stopProcessing="true">
<match url="^crond/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/crond/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 19" stopProcessing="true">
<match url="^invitation/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/invitation/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 20" stopProcessing="true">
<match url="^admin/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/admin/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 21" stopProcessing="true">
<match url="^m/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/m/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 22" stopProcessing="true">
<match url="^question/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/question/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 23" stopProcessing="true">
<match url="^category/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/home/explore/category/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 24" stopProcessing="true">
<match url="^feed/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/feed/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 25" stopProcessing="true">
<match url="^first_(.[i])$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/first_(.[/i])/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 26" stopProcessing="true">
<match url="^follow/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/follow/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 27" stopProcessing="true">
<match url="^weixin/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/weixin/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 28" stopProcessing="true">
<match url="^upgrade/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/upgrade/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 29" stopProcessing="true">
<match url="^help/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/help/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 30" stopProcessing="true">
<match url="^page/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/page/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 31" stopProcessing="true">
<match url="^article/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/article/{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 32" stopProcessing="true">
<match url="^sort_type-new__day-0__is_recommend-0__page/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/sort_type-new__day-0__is_recommend-0__page{R:1}" appendQueryString="false" />
</rule>
<rule name="已导入的规则 33" stopProcessing="true">
<match url="^m/(.*)$" ignoreCase="false" />
<action type="Rewrite" url="/\?\/m/{R:1}" appendQueryString="false" />
</rule>
<rule name="cnUrl 话题" stopProcessing="true">
<match url="^topic/(.*)$" />
<action type="Rewrite" url="cnurl.php" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404/404.html" responseMode="ExecuteURL" />
</httpErrors>
<urlCompression doDynamicCompression="true" />
</system.webServer>
</configuration>
测试地址 :www.tao258.cn
阅读全文
收起全文