iis下常用程序的偽靜態(tài)規(guī)則列表(包括wordpress、thinkphp)
作者:網(wǎng)站建設 | 發(fā)布日期:2021-01-29
shopex discuz2.0 discuz2.5 discuz3.x 淘寶客 ecshop phpwind參照http://www.west.cn/faq/list.asp?unid=797通過主機面板設置即可
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,在里面寫入以下規(guī)則(該規(guī)則適用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.默認的標簽前綴和分類目錄前綴有更改的情況下,規(guī)則如下
<?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)/(.*)$" />”需要根據(jù)實際目錄來修改,假如安裝在blog目錄,則應改為“<match url=”^blog/(tag|category)/(.*)$” />” 標簽前綴和分類目錄名稱根據(jù)實際目錄修改。
Thinkphp偽靜態(tài)規(guī)則:
手工創(chuàng)建web.config文件到站點根目錄
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url=".*\.(?:gif|jpg|png|css|js|txt|jpeg|swf|flv)" />
<action type="Rewrite" url="{R:0}" />
</rule>
<rule name="Imported Rule 2">
<match url="/httpd(?:\.ini|\.parse\.errors)" />
<action type="CustomResponse" url="/" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="^(?!/index.php)(?!/admin.php)(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

