ASP.NET Core:URL 重写不适用于静态文件

问题描述 投票:0回答:1
app.UseRewriter(new RewriteOptions().AddRedirect("login", "login.html")); //works
app.UseRewriter(new RewriteOptions().AddRewrite("login", "login.html", false)); //doesnt work

在第二种情况下,我收到错误 404,找不到页面。为什么? 该文件位于 wwwroot 目录中。

c# asp.net asp.net-core url-rewriting
1个回答
0
投票

请务必在

app.UseRewriter
之前致电
app.UseStaticFiles()

app.UseRewriter(new RewriteOptions().AddRewrite("login", "login.html", false)); 
app.UseStaticFiles();
© www.soinside.com 2019 - 2024. All rights reserved.