2011-09-06 23 views
22

Utilizo este código en el archivo web.config en una de las carpetas de mi sitio web para redirigir todas las páginas a la raíz porque quiero cerrar permanentemente esta sección.ASP.NET httpRedirect: redirigir todas las páginas, excepto una

<?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> 

pero tengo que hacer una excepción a esta regla: Yo no quiero que mi página "default.aspx" ser redirigir. ¿Cómo puedo hacer eso?

Respuesta

12

puede agregar un comodín de la siguiente manera, para redirigir solamente ciertos archivos:

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

pero no estoy seguro de si se puede negar que, por lo que no tiene en cuenta un determinado archivo.

34

Ponga su Default.aspx como <location> con httpRedirect deshabilitado. No importa si pone <location> antes o después de <system.webServer>.

<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> 
Cuestiones relacionadas