Static-web-apps: Possibility to enforce trailing slashes

Created on 1 Jun 2020  路  4Comments  路  Source: Azure/static-web-apps

It would be nice, if one could enforce trailing slashes at least for specific urls. In my case I would like
to forward /admin to /admin/, but doing that via the routes.json file results in a redirection loop.

enhancement needs discussion routing

Most helpful comment

I agree that this would be a nice feature. Often this comes up with default pages in subfolders that use relative URLs in links and access resources (like images) with relative URLs. Example:

If there's a file at /foo/bar/index.html, it can be accessed at all of the following locations:

  • /foo
  • /foo/
  • /foo/index.html

If there are any relative URLs in the page, those URLs will not work when accessing the page using /foo. To deal with this, most web servers will redirect /foo to /foo/.

Here's an example here:

/foo/index.html has a link <a href="bar.html">relative link to bar.html</a>:

@stephtr Is this the same scenario you're running into, or do you have other reasons to need this redirect?

All 4 comments

I agree that this would be a nice feature. Often this comes up with default pages in subfolders that use relative URLs in links and access resources (like images) with relative URLs. Example:

If there's a file at /foo/bar/index.html, it can be accessed at all of the following locations:

  • /foo
  • /foo/
  • /foo/index.html

If there are any relative URLs in the page, those URLs will not work when accessing the page using /foo. To deal with this, most web servers will redirect /foo to /foo/.

Here's an example here:

/foo/index.html has a link <a href="bar.html">relative link to bar.html</a>:

@stephtr Is this the same scenario you're running into, or do you have other reasons to need this redirect?

That's more or less exactly my use case.

Could you do two redirects?

redirect /foo => /temporary/
redirect /temporary/ => /foo/

Did anyone ever getting a resolution on this? Encountering the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AshirwadSatapathi picture AshirwadSatapathi  路  5Comments

krisnuttall picture krisnuttall  路  3Comments

mahmoudajawad picture mahmoudajawad  路  3Comments

stephtr picture stephtr  路  5Comments

akzaidi picture akzaidi  路  6Comments