I am trying to write rewrite rule the contains /p/ and ends with /
my rule is below
the rule is match for this url:
https://mysite.co.il/a/p/11/
but not match for this url:
https://mysite.co.il/p/11/
What is wrong with my rule?
<rule name="Remove trailing slash from /p/ URLs" stopProcessing="true">
<!-- Match URLs that contain /p/ and end with a trailing slash -->
<match url="^(.*)/p/(.*)/$" ignoreCase="true" />
<conditions>
<!-- Ensure it's not a physical file or directory -->
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<!-- Redirect to URL without trailing slash -->
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}/p/{R:2}" redirectType="Permanent" />
</rule>
Try to use ^((.*/)?p/(.*))/$
to match, and change the url="https://{HTTP_HOST}/{R:1}"
in your action