如果尚未安装 URL Rewrite 模块,请按以下步骤操作:
或者直接从 Microsoft 官网下载安装: URL Rewrite 模块下载
web.config
文件<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule" stopProcessing="true">
<match url=".*" />
<conditions>
<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>
.*
(匹配所有URL){REQUEST_FILENAME}
{REQUEST_FILENAME}
index.php
(根据你的程序入口文件调整)web.config
文件已正确放置在网站根目录web.config
文件格式是否正确iisreset
命令根据你的应用程序需求,可以自定义更复杂的规则。例如:
<rule name="Product Details">
<match url="^product/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="product.aspx?id={R:1}&name={R:2}" />
</rule>
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
通过以上步骤,你应该已经成功在 Windows Server 2019 的 IIS 上配置了伪静态支持。根据你的具体应用程序需求,可能需要调整上述规则。