說明:
作業系統:Windows Server 2012 R2
Web伺服器:IIS 8.5
網站程式:WordPress
網站根目錄:C:inetpubwwwroot
網站網域名稱:www.111cn.net
實現目的:
配置WordPress偽靜態
具體操作:
一、確認IIS 8.5是否安裝IIS URL Rewrite
開啟:控制台系統和安全管理工具Internet Information Services (IIS)管理器
看到URL重寫,說明已經安裝了IS URL Rewrite,否則要先安裝此外掛程式。
IIS URL Rewrite下載:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi
雙擊預設安裝即可
二、添加IIS 8.5偽靜態規則檔案
1、建立web.config檔案,添加以下代碼,儲存
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="category">
<match url="category/?(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="/index.php?category_name={R:1}" appendQueryString="false" logRewrittenUrl="false" />
</rule>
<rule name="tags">
<match url="tag/?(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="index.php?tag={R:1}" />
</rule>
<rule name="Main Rule" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:0}" />
</rule>
<rule name="wordpress" patternSyntax="Wildcard">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<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>
2、把web.config拷貝到網站根目錄:C:inetpubwwwroot下
三、設定WordPress
進入網站管理後台
設定-固定連結-自訂結構
填寫:/archives/%post_id%.html
儲存
系統營運 www.111cn.net 溫馨提醒:qihang01原創內容 著作權,轉載請註明出處及原文連結
如下圖所示