Closed RehanSaeed closed 6 years ago
This is not available for redirect rules. All effective redirect rules are considered terminal and no further rules are run. Does this work in other rewrite systems?
This seems to be called 'redirect chaining'. This blog post talks about how you can carry out a single redirect with IIS and avoid chaining. One other advantage to reducing chaining that I hadn't considered is that for every redirect you carry out, Google passes on less link juice, so it also hurts SEO.
Clever. That should mostly work for the current rule system. However, there's no built in rewrite version of the https rule, only a redirect version. It wouldn't be hard for you to make one though.
I haven't managed to test those UrlRewrite rules. but you may be able to copy it over and use it. However, we should consider giving an option that allows you to apply all rules and redirect afterwards on code rules.
My use case is a little more complicated than using the linked regex rules, I'd like to use a rewrite rule instead using code which also has the added benefit of being faster. Implementing some kind of pipeline so that the URL can be transformed by a sequence of rules would be useful.
The architecture would be pretty strange. You'd have to do a series of rewrite rules that set a flag if they changed anything, and then a final redirect rule that redirects to the resulting 'current' url if the flag is set. To build this in you'd need to define a new class of delayed redirect rules.
2.1 has added HttpsRedirectionMiddleware.
It would be nice for AddRedirectToHttps
to also support automatically setting the SSL port generally and in particular if a single redirect was implemented.
We don't think we'll be doing a large redesign here. Code rules are terminal, and this would require a redesign.
When using multiple rules with the rewrite middleware like so:
When I pass a URL that is both HTTP and has upper case characters, you get two redirects:
The first is the redirect from HTTP to HTTPS and the second is the redirect to the lower-case URL (not sure why Chrome dropped
/about
in the URL but it's there in the address bar). Ideally from a performance perspective, it should be possible to run all URL rewrite rules and apply a single redirect to the resultant URL. Is that currently possible? If not, what would it take to make it so?