2017-08-02 74 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你的幫助。謝謝 –