问题描述
我尝试在 Windows Server 2012 R2 中运行 wordpress,但在显示除 wordpress 主页之外的其他 wordpress 页面时遇到问题。
wordpress 文件在前。 wordpress 文件夹。
因此可以访问这些站点;
example.com/ – 这将成功返回 ASP.NET 网站
example.com/wordpress – 这将成功返回 wordpress 主页网站
但是当我访问不同的 wordpress 页面时,例如。
example.com/wordpress/about-us – 我收到一个错误说
“/”应用程序中的服务器错误。
无法找到该资源。
描述:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、更改名称或暂时不可用。请检查以下 URL 并确保其拼写正确。
请求的网址:/wordpress/about-us
版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.7.2106.0
*永久链接已使用此设置进行设置
example.com/wordpress/%postname%
*我也尝试过在 IIS 管理器上进行 URL 重写,但它不起作用。在 ASP.NET web.config 上它显示:
<rule name=”wordpress” enabled=”true” patternSyntax=”ECMAScript” stopProcessing=”true”>
<match url=”(wordpress/about-us).*” />
<action type=”Rewrite” url=”index.PHP” />
<conditions logicalGrouping=”MatchAny”>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” />
</conditions>
</rule>
wordpress 版本:5.6
PHP 版本:7.3.24
IIS 版本:8.5
有人可以帮我吗? ?
解决方法
WordPress 是用 PHP 编写的。如果您想在 Windows 机器(例如 IIS)中运行 WordPress,您可以在下载/安装 Windows 版 PHP 后在 IIS 管理器中设置模块映射。
例如,在 IIS 管理器的“操作”窗格中,您将能够选择“添加模块映射”。输入必要的详细信息以告诉 IIS *.php 文件应该由 php-cgi.exe 通过 FastCGI 运行。
,非常感谢大家的回复。
我在错误的配置文件上创建了重写规则。现在,我在“..安装 WordPress 文件的同一目录..”上创建了它,如下面的链接中的指南所述。
供他人参考: 创建重写规则的 web.config 文件路径: 前任。 C:\HostingSpaces\ASPWebsite\wordpress\web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="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" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>