-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
acceptedThis issue has completed "acceptance" testing (including accessibility)This issue has completed "acceptance" testing (including accessibility)area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares
Milestone
Description
Using the rewrite rule below, read in from the mod_rewrites.txt. The resulting redirect does not have the report id value as expected at the end of the url. The %1 should have the value matched from the backreference to the RewriteCond line. This rule works as I expect on Apache
To Reproduce
-
Using ASP.NET Core 2.2
-
Add mod_rewrites.txt with this rewrite rule in it
RewriteCond %{REQUEST_URI} /home
RewriteCond %{QUERY_STRING} report_id=(.+)
RewriteRule (.*) http://localhost:64782/home/report/%1 [R=301,L,QSD] -
Add this call in Startup.cs
using (var sr = File.OpenText("mod_rewrites.txt")) {
var rwo = new RewriteOptions().AddApacheModRewrite(sr);
app.UseRewriter(rwo);
}
- Add HomeController action
[HttpGet("/home/report/{id}")]
public IActionResult Report(int id)
{
return Content("rewritten id = " + id);
}
- Run and navigate to http://localhost:64782/home?report_id=123
Expected behavior
Rewritten URL is http://localhost:64782/home/report/123
Actual behavior
Rewritten URL is http://localhost:64782/home/report/
Additional context
This rewrite rule works as expected in Apache
Issue previously submitted as doc bug here
Metadata
Metadata
Assignees
Labels
acceptedThis issue has completed "acceptance" testing (including accessibility)This issue has completed "acceptance" testing (including accessibility)area-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares