Trailing slash redirect / adding IIS Rewrites
# help-with-umbraco
a
My current WIP project is running on a Azure Linux App service. I've added the requirements in my startup.cs
Copy code
csharp
        var rewriteOptions = new RewriteOptions()
            .AddIISUrlRewrite(env.ContentRootFileProvider, "IISUrlRewrite.xml");
        app.UseRewriter(rewriteOptions);
In my IISUrlRewrite.xml file I've added the trailing slash redirect as shown on the docs https://docs.umbraco.com/umbraco-cms/reference/routing/iisrewriterules#examples-of-rewrite-rules When I make a typo in my IISUrlRerwite.Xml file, an error appears, so atleast I know it's loaded/processed. However, I can't get it to work, neither locally, nor online on *.azurewebsite domain. Anyone have a suggestion of what I may have overlooked ?
s
Doubt it works at all without IIS, this is server dependent AFAIK. Try a rewrite module compatible with your actual server? Should be noted in the docs though.
a
Ye thats what I was wondering too, but I saw this piece: "On Linux, make sure to place the app.UseStaticFiles() after the app.UseUmbraco() statements for the redirect to work as intended." So I thought, oh, maybe its a .NET/Core thing that can just read IIS redirects and toss them to whatever it actually uses
As IIS wont run on Linux at all normally..
But it at leasts parses the rewrite file though
Using ChatGPT I've gotten an nice example, if it works ill update the docs 🙂
d
@Ambert This should work, shouldn't need IIS and should be platform agnostic. I think it will be important where in the pipeline it's registered, i.e. before mostly everything, even Umbraco. IIS would ordinarily sit in front of Umbraco (as would an .htaccess file), so it's important that your redirect module does too. Obviously, theres nothing stopping you putting it elsewhere but you risk other things i your pipeline affecting your static redirects. We often have two redirect modules registered, one which sits infront of everything (based on some configured rules) and one for custom CMS managed redirects.
a
I've switched it to
Copy code
csharp
        var rewriteOptions = new RewriteOptions()
            .AddApacheModRewrite(env.ContentRootFileProvider, "rewrites.conf");
and used a htaccess redirect, and that worked though
Perhaps the example redirect is wrong somehow, or I failed 😅 , i'll double check it, thanks though @digbyswift
3 Views