ASP.NET Core 2.1.
My favicon is at /images/favicon.ico
and cannot be changed. So pages include this:
<link href="/images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
And that works.
But requests directly to example.com/favicon.ico
will fail with a 404.
How do I redirect example.com/favicon.ico
to example.com/images/favicon.ico
?
In the Configure
method of your Startup
class, add the following code
RewriteOptions rewriteOptions = new RewriteOptions().AddRedirect("favicon.ico", "images/favicon.ico");
app.UseRewriter(rewriteOptions);
See this page for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With