I am trying to get URLRewriter to force redirect a HTTP requests to a HTTPS. The vendors documentation doesn't seem to cover it.
I know the following parameters throws an error but serve to illustrate what I am trying to accomplish:
<rewriter>
<if url="http://www.domain.com/test*">
<rewrite url="http://www.domain.com/test*" to="https://www.domain.com/test*" />
</if>
</rewriter>
It would be useful to know exactly what error is thrown to make sure I am heading down the right path here but I think you are using the * character when you mean to use the . character (possibly .+ if you are intending any non secure URL to be redirected to the secure version)
It seems like what the original poster wanted to do was something like:
<rewriter>
<if url="http://.*">
<rewrite url="http://([^/]*)(.*)" to="https://$1$2" />
</if>
</rewriter>
However, that doesn't seem to work at all - I'm not really sure what it's doing under the hood to understand why. The regexes seem to be sound. I found this site really helpful for figuring some of this out: http://regexhero.net/tester/
I finally found the magic incantation to make it work, from:
https://webmasters.stackexchange.com/a/31318
<rewriter>
<if header="HTTPS" match="^OFF$">
<redirect url="(.*)" to="https://yourdomain.com$1"/>
</if>
</rewriter>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With