【发布时间】:2019-07-25 21:45:03
【问题描述】:
我的 Wordpress 环境在 IIS/Azure 上运行。我有一个需要帮助的 web.config 文件。我已经成功地将所有带有斜杠的 URL 的流量永久重定向到没有斜杠的同一个 URL。效果很好,除了我需要为一条路径否定这条规则,这样我就不会破坏 Wordpress 提供的 wp-json (API) 功能。
我试了一下,但这条否定规则似乎不起作用。
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^\wp-json$" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
我想要豁免的 URL 仍然重定向到非斜杠 URL,在这种情况下,我需要保留斜杠。
【问题讨论】:
标签: wordpress web-config trailing-slash