说明:
操作系统:Windows Server 2012 R2
Web服务器:IIS 8.5
网站程序:WordPress
网站根目录:D:\wwwroot
实现目的:
配置WordPress伪静态
具体操作:
一、确认IIS 8.5是否安装IIS URL Rewrite
二、添加IIS 8.5伪静态规则文件
第一种方法:
把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
保存