# win2k3+iis下wordpress的伪静态设置httpd.ini

- Link: https://yjyj.net/learn/wordpress-learn/1704.html
- Published: 2012-12-07T21:32:20+08:00
- Author: 小 虾

⚡ 生猛大蝦编辑部 · 30 秒核心看点

 * 用 httpd.ini 给 WordPress 做伪静态，核心是把请求统一转到 index.php。
 * 规则里同时放行图片、sitemap、favicon 和 wp 目录，避免误伤静态资源。
 * 这套写法适合 Win2k3+iis 老环境，属于可直接备份留存的实战配置。

    ```decode:true
    [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]
    RewriteRule /wap(.*) /wap$1 [L]
    # For normal wordpress content, via index.php
    RewriteRule ^/$ /index.php [L]
    RewriteRule /(.*) /index.php/$1 [L]
    ```

记录一下 以备不时只需

❓ 延伸问答与排错指南（FAQ）

Win2k3+iis 下 WordPress 伪静态怎么写？

可在 httpd.ini 的 ISAPI_Rewrite 段里配置重写规则：先放行 tag、静态资源、sitemap、
favicon 和 wp 相关路径，再把站点根目录及普通请求统一转到 index.php。这样能兼顾 WordPress
文章链接和资源访问。

为什么要单独放行图片和 wp 目录？

因为 WordPress 主题、后台和附件常依赖这些路径，若全部强制重写，容易导致图片打不开、
后台异常或静态文件失效。先放行再重写，是老 IIS 环境里更稳的做法。

这类 httpd.ini 规则适合哪些场景？

适合运行在 Win2k3+iis、使用 ISAPI_Rewrite 的老站点，尤其是想把 WordPress 链接做成
伪静态、同时保持静态资源正常访问的场景。配置后建议逐项测试首页、文章页、图片和后台。

📚 【[WordPress 学习](https://yjyj.net/category/learn/wordpress-learn)】专栏延伸
阅读与热门精选（[全站文章归档](https://yjyj.net/archive)）：

 * [终于找到一个能用的WordPress不同分类下的文章使用不同样式的模板](https://yjyj.net/learn/wordpress-learn/1700.html)
 * [WordPress实现箭头翻页功能（代码版）](https://yjyj.net/learn/wordpress-learn/1697.html)
 * [使用WP-PostViews插件统计不了浏览量的问题](https://yjyj.net/learn/wordpress-learn/2868.html)
 * [WordPress 教程：如何在 WordPress 站点创建后门](https://yjyj.net/learn/wordpress-learn/3406.html)
 * 热门必读[解决: windows 环境下 无法将“git”项识别为 cmdlet、函数、脚本文件或可运行程序的名称](https://yjyj.net/learn/7776.html)
 * 热门必读[DMIT 全线缺货, 只剩搬瓦工了](https://yjyj.net/discover/7787.html)
