Forum

Protocol-agnostic redirect possible?

Rodney Hester
17 October 2013, 18:15
Simple issue, really, but I'm having difficulty finding the solution.

If a user comes into: http://www.foo.com/ (i.e. no URI), I want them to be redirected to: http://www.foo.com/bar/

If they come into: https://www.foo.com/, I want them redirected to: https://www.foo.com/bar/

So in other words, I want to honor whatever protocol they first hit with, be it port 80 or 443.

This is trivial to achieve via Rewrite, but that hides the URI change from the user, which I'd like to be visible and obvious to them.

If I do it via Redirect instead, I have to explicitly specify the protocol in the redirect URL, and I can't find any way to have two separate Match stanzas that apply to 80 and 443 separately.

Any thoughts, short of a (probably not-working-properly) HTML-side redirect? I'd really like to handle this within Hiawatha if possible.

Also, Hugo, thanks a LOT for finally reconsidering reverse proxy support. I'm using it now to ensure full SSL compatibility (even over IPv6, yay!), and it's working wonderfully!

Rodney
Hugo Leisink
17 October 2013, 18:24
You don't have to specify the complete URL. If it's within the same website, the path will be sufficient.
UrlToolkit {
ToolkitID = redirect
Match ^/$ Redirect /bar/
}
Rodney Hester
17 October 2013, 19:17
I could have sworn I'd tried that already...but you're right, it works like a charm! Thank you!

Rodney
This topic has been closed.