2017-08-02 75 views
0

我有一个设置IIS URLRewrite条件的问题,以便在输入的url无效时将它带到设置的url。例如,你输入url:example.local/current_work这将是一个有效的网址,所以它显示的网页,但是为url:example.local/this_doesnt_exist它会重新引导你回到example.local/current_work等...如何在IIS中设置条件UrlRewrite以检查URL是否有效

希望我明白这一点。

<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网址应该以相同的方式工作。

预先感谢您。

+0

你想创建重定向'example.local/this_doesnt_exist'为'example.local/current_work'。只为这个网址?或者你有没有不存在的网址列表? –

+0

只为这个网址,谢谢 –

回答

0

此规则将重定向到example.local/this_doesnt_existexample.local/current_work

<rule name="Test" stopProcessing="true"> 
    <match url="^this_doesnt_exist$" /> 
    <action type="Redirect" url="/current_work" /> 
</rule> 
+0

伟大的工程,但我的意思是说,重定向到example.loca/current_work从任何无效的网址不只是“this_doesnt_exist”。对不起我的坏 –

+0

嗯,可能对你更好,只是设置自定义404页面 ' ' –

+0

感谢Victor,但是您认为仅仅通过IIS url重写就可以做到这一点吗? Apreciate你的帮助。谢谢 –