Windows 2008 IIS 7.x + WordPress 伪静态固定链接失效修复

2020年11月6日 2008点热度 1人点赞 1条评论

最近 Windows 2008 服务器被攻击入侵了,导致被百度收录了菠菜页面,点击后跳转至菠菜网站页面。花了好些时间查找文件,测试数据库等,最后实在搞不定了,备份数据,重新安装服务,恢复数据再测试,居然顺利的修复了问题,真的是庆幸。但是,服务器上的 WordPress 网站伪静态固定链接却失效了,一直 404 页面。经过搜索引擎多次查询,尝试了多种方法,最终才修复。

以前不熟悉 Linux 系统,纯小白,就安装了 Windows 系统的 PHP 环境,真的问题不少。现在感觉别以为 Windows 系统比 Linux 系统容易入手,对于 PHP 环境而言,Windows 系统是真的很多坑,分分钟搞到让你怀疑人生。反而 Linux 系统,稍稍记一点命令,装个 Web 面板管理还要更好用。当然,这个也使用服务器环境架设工具有关,我这里说的 Windows 系统主要是用来运行 .Net 程序的网站,然后,手动配置了 PHP 环境,所以难免会有不少坑。

Windows 2008 IIS + PHP + MySQL 环境配置这里就不多说了,网上有很多教程,我以前也弄过一份电子文档教程上传了百度文档,后来都不知道是不是被删了,好久没有看到了。手动配置 Windows 的 PHP 环境不算特别难,但是,WordPress 伪静态的这部分,固定链接这里还是踩了不少坑。这里分享一下 IIS 7.x 的 WordPress 伪静态规则:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
		<modules>
		  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
		</modules>
        <rewrite>
            <rules>
                <rule name="WordPress Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                        <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 Default 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" appendQueryString="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

IIS 7.x 需要安装 URL 重写模块: 点击前往下载

安装成 URL 重写模块后

这一次伪静态固定链接失效的最大原因就是 URL 重写模块出现了问题,重新安装 URL 重写模块就完美的解决问题。

WPTalk

这个人很懒,什么都没留下

文章评论

您需要 登录 之后才可以评论