Forum Discussion
arundoss
May 11, 2024Copper Contributor
Default document not showing while using IIS as a reverse proxy server
I am using IIS as a reverse proxy for multiple applications using URL rewrite module. I have wrote a rule like "App/?(.*)" to match the application path.
The default document which is a "Home.aspx" file is loading when I put a path like "https://localhost/App/" but, if I remove the last forward-slash like "https://localhost/App" it is not working.
I understand that the rule is written to consider only after the slash, but any way I can rewrite the rule to written the default document without the last slash as well ? Kind suggest.
- DeletedEntiendo tu problema con el reescritor de URL en IIS. Sí, es posible reescribir la regla para que también maneje las URL sin la barra diagonal final. Puedes ajustar la regla de reescritura para que coincida tanto con las rutas con y sin la barra diagonal final. Aquí tienes un ejemplo de cómo hacerlo:
```xml
<rewrite>
<rules>
<rule name="RewriteApp" stopProcessing="true">
<match url="^App/?(.*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/App/Home.aspx" />
</rule>
<rule name="RewriteAppNoTrailingSlash" stopProcessing="true">
<match url="^App$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/App/Home.aspx" />
</rule>
</rules>
</rewrite>
```
En este ejemplo, hay dos reglas:
1. La primera regla `RewriteApp` maneja las URL que terminan con o sin una barra diagonal y luego reescribe la URL a `/App/Home.aspx`.
2. La segunda regla `RewriteAppNoTrailingSlash` maneja las URL que no tienen la barra diagonal final (`^App$`) y las reescribe también a `/App/Home.aspx`.
Con estas dos reglas, deberías poder manejar tanto las rutas con y sin la barra diagonal final correctamente.
Prueba esto y dime cómo te va. ¿Algo más que quieras ajustar o revisar?[](https://github.com/NilsDannemann/nilsdannemann.dev/tree/cc8591693e4bf56e5b31ad5c6d28295451721aa0/wp-includes%2Fclass-wp-rewrite.php "1")[](https://github.com/DiscipleTools/Documentation/tree/2c7e9c6744b4d01fe3ca4140a80a79c5ebe5dbda/hosting%2Fhosting.md "2")
Ojalá te pueda servir este mensaje