2015-11-02 55 views
0

重定向特定的Default.aspx到/我們的網站上有這樣的結構:通過web.config中

http://localhost/default.aspx

http://localhost/aboutus/default.aspx

http://localhost/resources/default.aspx

http://localhost/mobile/default.aspx

當我添加了以下規則web.config中,它被重定向所有的Default.aspx到/

<rule name="Default Document" stopProcessing="true"> 
       <match url="(.*)default.aspx" /> 
       <action type="Redirect" url="{R:1}" redirectType="Permanent" /> 
      </rule> 

我只想只有兩種這些URL重定向到/

http://localhost/default.aspx重定向到http://localhost/

http://localhost/mobile/default.aspx重定向到http://localhost/mobile/

燦ÿ你需要幫忙嗎?提前致謝。

+0

有什麼建議?幫幫我 – lambda8

回答

0

這是解決方案:

   <rule name="root homemobile" stopProcessing="true"> 
        <match url="^mobile/Default.aspx" ignoreCase="true" /> 
        <action type="Redirect" url="/mobile/" redirectType="Permanent" /> 
       </rule> 
       <rule name="root home" stopProcessing="true" patternSyntax="ExactMatch"> 
        <match url="Default.aspx" ignoreCase="true" /> 
        <action type="Redirect" url="/" redirectType="Permanent" /> 
       </rule> 
相關問題