Rewriting slashes in the query parameter

In my main asp.net application (angular 4 front end) I accept the following URL:

example.com/report;url=http%3A%2F%2Fexample2.com

I would like to create a rewrite rule that allows people to enter the following URL:

example.com/report;url=http://example2.com

I can’t figure out how to do this.

I tried:

var options = new RewriteOptions()
    .AddRewrite(@"(.*);url=http:\/\/([^;]*)(.*)", "$1;url=http%3A%2F%2F$2$3", skipRemainingRules: false)
    .AddRewrite(@"^report.*", "index.html", skipRemainingRules: true)

app.UseRewriter(options);

This did not work, but even if it were, it would not take into account URLs that have slashes after the domain, that is, subdirectories. Using the group matching pattern, I think this is impossible to do. This should be a search and replace operation in the corresponding group.

Other web servers have this as a custom option for decoding a slash. I cannot find links to it in the main asp.net docs. Is it possible?

+6
2

URL. , , URL- . .

:

http://example.com/report;url=http%3A%2F%2Fexample2.com

:

http://example.com/report?url=http%3A%2F%2Fexample2.com

, , , submit. URL-, URL- "url".

URL-, , .

0

Source: https://habr.com/ru/post/1016250/


All Articles