My Wordpress environment is running on IIS/Azure. I have a web.config file that I need help with. I am already successfully permanently redirecting traffic from all URLs with a trailing slash to the same URL without that slash. Works great, except I need to negate this rule for one path so I don't break the wp-json (API) functionality supplied by Wordpress.
I took a stab at it, but this negate rule doesn't seem to work.
<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>
The URL I want exempt is still redirecting to a non trailing slash URL where in this case I need the trailing slash to remain.