Extensionless url with jekyll on azure webapp

Oct 12, 2017. | By: Owen Davies

This blog is built using Jekyll, a static site generator. It’s by far my favourite blogging platform these days. Mostly due to simplicity. There is no database, and once the site is deployed…It’s just pure html files. Very little to manage.

But I want extensionless urls, how can we accomplish this?

Azure Webapp web.config file

To get our extensionless URLs we can create a standard web.config file in the root of our webapp with the following rewrite rules.

<?xml version="1.0" encoding="utf-8"?>
<configuration>

	 <system.webServer>
     <rewrite>
        <rules>
            <rule name="extensionless" stopProcessing="true">
                <match url="(.*)\.html$" />
                <action type="Redirect" url="{R:1}" redirectType="Permanent" />
            </rule>
            <rule name="removeextension" enabled="true">
                <match url=".*" negate="false" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="{R:0}.html" />
            </rule>
        </rules>
    </rewrite>
  </system.webServer>
</configuration> 

Comments

About

Founded in 2009, Odity is a software consultancy based in the United Kingdom.

Social Links

Our Bunker

United Kingdom.