url-rewritingtuckey-urlrewrite-filter

UrlRewriteFilter: www and https redirect


I am using Tuckey UrlRewriteFilter to force users to go to the 'www' and 'https' version of my web. I mean next 3 URLs must redirect to https://www.myweb.com

The problem comes with the last one, I cannot find the solution to put 'www' for 'https'. I have the next rule that makes 2 first cases work without problems:

  <rule>
    <name>Domain Name Check</name>
    <condition name="host" operator="equal">myweb.com$</condition>
    <condition type="scheme" operator="equal">^http$</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">https://www.myweb.com$1</to>
  </rule>

This one of course does not apply for the third case. If I try a similar rule for the third case like the following, it doesn't work either (I don't know why):

  <rule>
    <name>Domain Name Check</name>
    <condition name="host" operator="equal">myweb.com$</condition>
    <condition type="scheme" operator="equal">^https$</condition>
    <from>^(.*)$</from>
    <to type="permanent-redirect">https://www.myweb.com$1</to>
  </rule>

Could you please help me to figure out the rule for the third case?

Thank you.


Solution

  • The problem was not the filter but my certificate. I issued my certificate for www.myweb.com but not for myweb.com so https://myweb.com request didn't reach my server, the browser detected the certificate was not valid and blocked the process.

    I just issued my certificate for https://myweb.com and modified my Tuckey rule as you can see below. Now https://www.myweb.com is the only URL users can use.

      <rule> 
        <name>Domain Name Check</name>
        <condition type="request-url" operator="equal">(^http://myweb.com|^http://www.myweb.com|^https://myweb.com)</condition>
        <from>^(.*)$</from>
        <to type="redirect">https://www.myweb.com$1</to>
      </rule>