Skip to content

How do I exclude UmbPanel domains from www redirects?

If your site enforces a www → non-www redirect (or vice versa), you must exclude all *.umbpanel.io domains from that redirect when running on GreenStack.

GreenStack serves your site — including the back office and the live preview — over *.umbpanel.io URLs. A redirect that rewrites the host has two consequences:

  • It breaks access through the preview URL. Requests to your *.umbpanel.io address get redirected away to your production host, so you can no longer reach the back office or preview the site there.
  • It breaks the load balancer. GreenStack’s health checks reach your container over its *.umbpanel.io domain. A redirect response (rather than a 200) causes the check to fail, so your container is pulled out of rotation and the site goes down.

GreenStack runs your site on Kestrel, not IIS, so there is no web.config. There are two supported ways to set up the redirect — in both cases the goal is to ensure *.umbpanel.io is never redirected.

Umbraco can load IIS-style rewrite rules from an iisrewrite.xml file via the URL Rewrite middleware (see the Umbraco URL Rewrites documentation). Add a negate condition so umbpanel.io hosts are skipped:

<?xml version="1.0" encoding="utf-8" ?>
<rewrite>
<rules>
<rule name="Redirect www to non-www" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
<!-- Don't redirect UmbPanel domains -->
<add input="{HTTP_HOST}" pattern="umbpanel\.io$" negate="true" />
</conditions>
<action type="Redirect" url="https://{C:1}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>

Register it in Program.cs (for a Startup.cs project, add it in the Configure method using env.ContentRootFileProvider):

using Microsoft.AspNetCore.Rewrite;
var rewriteOptions = new RewriteOptions()
.AddIISUrlRewrite(builder.Environment.ContentRootFileProvider, "iisrewrite.xml");
app.UseRewriter(rewriteOptions);
// On Linux, UseStaticFiles() must come AFTER the UseUmbraco() statements
// for the rewrites to take effect.
app.UseStaticFiles();

Make sure the file is copied to the build output in your .csproj:

<ItemGroup>
<Content Include="iisrewrite.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>

Option 2 — Built-in redirect middleware in Program.cs

Section titled “Option 2 — Built-in redirect middleware in Program.cs”

The ASP.NET Core rewrite middleware has built-in www redirect helpers. Pass only your production host(s) to the domains parameter — the rule then fires only for those hosts, so *.umbpanel.io is never matched and never redirected:

using Microsoft.AspNetCore.Rewrite;
// Redirect www → non-www for your production host only.
// UmbPanel domains aren't listed, so preview URLs and health checks keep working.
var rewriteOptions = new RewriteOptions()
.AddRedirectToWww("example.com");
app.UseRewriter(rewriteOptions);
// On Linux, UseStaticFiles() must come AFTER the UseUmbraco() statements.
app.UseStaticFiles();

Note: The examples show a www → non-www redirect. For the opposite direction use AddRedirectToWwwPermanent and list your bare domain (e.g. example.com). Either way, *.umbpanel.io must never be redirected.