2011-09-06 10 views
22

hariç tüm sayfaları yeniden yönlendirme Bu kodu web sayfamın klasörlerinden birinde web.config içinde kullanıyorum, çünkü bu sayfayı kalıcı olarak kapatmak istiyorum.ASP.NET httpRedirect: bir

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
<location> 
    <system.webServer> 
     <httpRedirect enabled="true" destination="http://www.example.com/" httpResponseStatus="Permanent" /> 
    </system.webServer> 
    </location> 
</configuration> 

Ama bu kurala bir istisna yapmak gerekir: Ben yönlendirmek olmak benim sayfa "default.aspx" istemiyoruz. Bunu nasıl yapabilirim?

cevap

12

Eğer aşağıdaki şekilde bir joker ekleyebilir sadece belirli dosyaları yeniden yönlendirmek için:

<configuration> 
     <system.webServer> 
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found"> 
      <add wildcard="*.php" destination="/default.htm" /> 
      </httpRedirect> 
     </system.webServer> 
    </configuration> 

Ama belli bir dosyayı görmezden böylece, o inkâr eğer emin değilim.

34

Default.aspx'inizi, httpRedirect devre dışıyken <location> olarak girin. <system.webServer>'dan önce veya sonra <location> koyarsanız farketmez.

<configuration> 
    <system.webServer> 
     <httpRedirect enabled="true" destination="http://www.example.com/" exactDestination="true" httpResponseStatus="Permanent" /> 
    </system.webServer> 
    <location path="Default.aspx"> 
     <system.webServer> 
      <httpRedirect enabled="false" /> 
     </system.webServer> 
    </location> 
</configuration>