Smart URLRewriter HTTP for HTTPS

I'm trying to get the URLRewriter to force redirect HTTP requests to HTTPS. Vendor documentation does not cover it.

I know the following parameters are causing 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>

      

+3


source to share


2 answers


It would be helpful to know exactly what the error is, to make sure I am following the right path here, but I think you are using the * character when you want to use. (possibly + if you intend to redirect any protected URL to the secure version)



+2


source


It looks 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, it doesn't seem to work at all - I'm not entirely sure what it does under the hood to see why. Regular expressions appear to be sound. I found this site very helpful for understanding what came of it: http://regexhero.net/tester/



I finally found a magic spell 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>

      

+2


source







All Articles