繁体   English   中英

使用 ASP.NET 站点在 IIS 上运行 WordPress

[英]Run WordPress on IIS with ASP.NET site

I am trying to run WordPress in Windows Server 2012 R2 and encountered an issue on displaying other WordPress pages except for the WordPress homepage.

WordPress 文件位于 ex。 wordpress 文件夹。

因此这些网站可以在以下位置访问;
example.com/ - 这成功返回 ASP.NET 网站
example.com/wordpress – 这成功返回 WordPress 主页网站

但是当我访问不同的 WordPress 页面时,例如。
example.com/wordpress/about-us – 我收到一条错误消息

“/”应用程序中的服务器错误。

无法找到该资源。

描述:HTTP 404. 您正在查找的资源(或其依赖项之一)可能已被删除、更改名称或暂时不可用。 请查看以下 URL 并确保拼写正确。
请求 URL:/wordpress/about-us
版本信息:Microsoft .NET 框架版本: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 中。 If you want to run WordPress in a windows machine (eg IIS), you may set Module Mapping in your IIS manager after you have downloaded / installed PHP for windows.

例如,在 IIS Manager 的 Actions 窗格中,您将能够选择“Add Module Mapping”。 输入必要的详细信息,告诉 IIS *.php 文件应该由 php-cgi.exe 通过 FastCGI 运行。

非常感谢大家的回复。

我在错误的配置文件上创建了重写规则。 现在,我在“..安装 WordPress 文件的同一目录..”上创建了它,正如下面链接中的本指南所述。

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/enabling-pretty-permalinks-in-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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM