wordpress设置windows2012系统伪静态设置教程

wordpress设置windows2012系统伪静态设置教程

说明:

操作系统:Windows Server 2012 R2

Web服务器:IIS 8.5

网站程序:WordPress

网站根目录:D:\wwwroot

实现目的:

配置WordPress伪静态

具体操作:

一、确认IIS 8.5是否安装IIS 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伪静态规则文件

第一种方法:

<?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>

把web.config拷贝到网站根目录D:\wwwroot里面

第二种方法:

IIS 环境是 Windows 主机常用的服务器环境,新建一个 txt 文件,将下面的代码添加到文件中:

[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour

CacheClockRate 3600
RepeatLimit 32
 
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through

RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]

然后另存为 httpd.ini 文件,上传到WordPress站点的根目录即可。

三、设置WordPress

进入网站管理后台

设置-固定链接-自定义结构

填写:/archives/%post_id%.html

保存

原创文章,作者:开心电脑网,如若转载,请注明出处。

(1)
上一篇 2018年5月1日
下一篇 2018年7月29日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注