如何在 IIS UrlRewrite 中设置条件以检查 URL 是否有效
How to set a condition in IIS UrlRewrite to check if the URL is valid
我在为我的 IIS URLRewrite 设置条件时遇到问题,因此当输入的 url 无效时,它会将您带到一个集合 url。例如,您键入 url: example.local/current_work 这将是一个有效的 url 因此它显示页面但是对于 url : example.local/this_doesnt_exist 它将重定向你回到例子。local/current_work 等...
希望我清楚这一点。
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="^scottishtrunkroadsse.amey.local/([_0-9a-z-]+)" negate="false"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="current-works/" />
</rule>
</rules>
<rewrite>
感谢您的帮助。
我正在使用 Umbraco 网站,但我不认为这有任何改变,因为 IIS url 应该以相同的方式工作。
提前致谢。
此规则会将 example.local/this_doesnt_exist
重定向到 example.local/current_work
:
<rule name="Test" stopProcessing="true">
<match url="^this_doesnt_exist$" />
<action type="Redirect" url="/current_work" />
</rule>
我在为我的 IIS URLRewrite 设置条件时遇到问题,因此当输入的 url 无效时,它会将您带到一个集合 url。例如,您键入 url: example.local/current_work 这将是一个有效的 url 因此它显示页面但是对于 url : example.local/this_doesnt_exist 它将重定向你回到例子。local/current_work 等...
希望我清楚这一点。
<rewrite>
<rules>
<rule name="Test" stopProcessing="true">
<match url="^scottishtrunkroadsse.amey.local/([_0-9a-z-]+)" negate="false"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Redirect" url="current-works/" />
</rule>
</rules>
<rewrite>
感谢您的帮助。
我正在使用 Umbraco 网站,但我不认为这有任何改变,因为 IIS url 应该以相同的方式工作。
提前致谢。
此规则会将 example.local/this_doesnt_exist
重定向到 example.local/current_work
:
<rule name="Test" stopProcessing="true">
<match url="^this_doesnt_exist$" />
<action type="Redirect" url="/current_work" />
</rule>