app.UseRewriter(new RewriteOptions().AddRedirect("login", "login.html")); //works
app.UseRewriter(new RewriteOptions().AddRewrite("login", "login.html", false)); //doesnt work
In the second case i get error 404, page not found. Why? The file is in the wwwroot directory.
Be sure call app.UseRewriter
before app.UseStaticFiles()
, otherwise the RewriteMiddleware
might be superseeded by the one in charge of the static files, which could mess up your rewrite rules:
app.UseRewriter(new RewriteOptions().AddRewrite("login", "login.html", false));
app.UseStaticFiles();