How to set up redirects properly for the site on Azure Static Webapp using Jekyll

Rndwork 1 Reputation point
2021-10-10T15:08:17.97+00:00

Hi all! We made a static website using Jekyll on Azure Static Webapp and faced a dilemma on how to properly set up different types of redirects necessary for SEO and not only.

Some of the main redirects that we need are:

  1. Support Non-Trailing Slash Urls - redirect the Urls with / at the end to the url without it
  2. Remove .html - by default the same pages on jekyll are accessible both with .html and without it, I would like to redirect pages with .html to the same url without it
  3. Implement lower case url rule - so that when typing the url all the upper case letters would convert to the lower case by redirect
  4. http errors - 404 page - by default Azure's page is shown, I would like to show our own version of it.

First I've tried to create web.config file in the root folder and follow this instruction - https://rimdev.io/jekyll-and-iis-web-configuration-in-windows-azure/ but nothing changed and it seems that this approach is not working.

Then I tried to use the staticwebapp.config.json file. I managed to implement only local redirects, like page 1 to page 2, but not global ones.

Does anybody have any positive experience in this? What is the best approach to take and how ti implement all these redirects? And why web.config is not working (I put it in root folder)? May be there are some settings that need to be turned on in Azure admin to make it work? That would be the easiest way to implement those redirect.
BTW I used this guide to create the website - https://learn.microsoft.com/en-us/azure/static-web-apps/publish-jekyll

Please advise! Thanks!

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
966 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anthony Chu - MSFT 861 Reputation points Microsoft Employee
    2021-10-10T21:05:51.21+00:00

    We’re working on some new settings that should help with this.

    For 1 and 2 above, sound like you have a file at /foo.html and you are looking for this behavior:
    Requests to /foo serves the page.
    Requests to /foo/ redirects to /foo.
    Requests to /foo.html redirects to /foo.

    Can you confirm that this is what you’re looking for? How important is it that /foo.html redirects to /foo?

    For 3, we don’t have anything planned for this. Our routes and filesystem are currently case sensitive.

    For 4, see the response overrides configuration: https://learn.microsoft.com/en-us/azure/static-web-apps/configuration#response-overrides


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.