Alamakanambra
Alamakanambra

Reputation: 7826

URL without .html extension on azure web app does not work

I have got links on my static website. These links are without .html extension.

https://zodoc.azurewebsites.net/posts/en/selective_blur - does not work

Error: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

https://zodoc.azurewebsites.net/posts/en/selective_blur.html - works fine

How to make it work without .html extension?

Upvotes: 2

Views: 1165

Answers (1)

Joey Cai
Joey Cai

Reputation: 20067

As rickvdbosch said, you could use URL rewrite to remove the .html extension in your URL.

Open the web.config and insert the following code inside the system.webServer node.

<rewrite>
      <rules>
          <rule name="RewriteURL" stopProcessing="true">
              <match url="^(.*)$" />
              <conditions>
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
              </conditions>
              <action type="Rewrite" url="{R:1}.html" />
          </rule> 
     </rules>
 </rewrite>

Upvotes: 2

Related Questions