Reputation: 7601
Say, I want to turn this: www.example.com/homepage.html
to this www.example.com/homepage
What should I change in my Azure portal or config in order to achieve this?
Upvotes: 0
Views: 1113
Reputation: 968
You could place this block of code in your web.config
file.
<rewrite>
<rules>
<rule name="Hide .html ext">
<match ignoreCase="true" url="^(.*)"/>
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
<add input="{REQUEST_FILENAME}.html" matchType="IsFile"/>
</conditions>
<action type="Rewrite" url="{R:0}.html"/>
</rule>
<rule name="Redirecting .html ext" stopProcessing="true">
<match url="^(.*).html"/>
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="(.*).html"/>
</conditions>
<action type="Redirect" url="{R:1}"/>
</rule>
</rules>
</rewrite>
This will remove the .html
extension from every html file. So, for example, if you open a file called index.html it would be shown as index and if you request the file index it will be shown the index.html file (the extension will not be shown).
This works both on Azure and on IIS, so if in a future you would move to IIS, you could do without changing anything.
I hope i helped you.
Upvotes: 3