-
Notifications
You must be signed in to change notification settings - Fork 136
URL Rewrite
Edi Wang edited this page Oct 28, 2020
·
1 revision
The url rewrite rules for Moonglade are controlled at web server level, not from ASP.NET Core kestrel. Because:
- Different users have different rewrite rules, I can not hard code it into
startup.cs
- Web server like IIS, Nginx or LB, WAF can provide much richer and flexibility to set url rewrite rules
You must install IIS URL Rewrite Module before deploy to IIS.
The ./src/Moonglade.Web/web.Release.config
is a default web.config transformation file to set url rewrite rules.
<rewrite xdt:Transform="InsertIfMissing">
<rules>
<rule name="Redirect Misc Homepage URLs to canonical homepage URL" stopProcessing="false">
<match url="(index|default).(aspx?|htm|s?html|php|pl|cfm)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_METHOD}" pattern="GET"/>
</conditions>
<action type="Redirect" url="/"/>
</rule>
<rule name="RemoveTrailingSlashRule" stopProcessing="true">
<match url="(.*)/$"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
</conditions>
<action type="Redirect" url="{R:1}"/>
</rule>
</rules>
</rewrite>
I am not a Linux guy, this need some time to research...