0

Lately I've installed a SSL certificate for a website on a IIS 7.5 webserver. Then i set up a URL rewrite rule to rewrite HTTP to HTTPS. So far almost everything is working except for one thing. If i type the domain and then /language like /en then the URL rewrite doesn't work. The website is running on Drupal 7. So for example if i go to the contact page like www.domain.com/contact then the URL gets rewritten by Drupal to www.domain.com/language(like EN of FR, etc..)/contact, the language is detected by the browser language. I think this rewrite causes the URL rewrite rule to fail or ignore the URL request thus no HTTP to HTTPS redirection.

But when i first go the the homepage: www.domain.com and then click on the menu buttons to go to the contact page everything works. HTTP gets redirected to HTTPS. This because i think the language redirect was already made so the URL rewrite module can handle the new URL rewrite request.

This is the rule i'm using, tried alot of different once all similair results.

  <rule name="HTTP to HTTPS redirect" enabled="false" stopProcessing="true">
    <match url="http://(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
    <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
   </rule>

OR

    <rule name="HTTP to HTTPS redirect2" stopProcessing="true">
      <match url="(.*)" />
      <!-- Require SSL must be OFF in the site settings -->
      <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
      </conditions>
      <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
    </rule>
3
  • In your first rule, doesn't {R:1} contain the hostname, so your Location header contains it twice? – Gerard H. Pille Jan 18 '18 at 9:44
  • I can see in the Request headers that the the Host = www.example.com. However in the General Headers the Request URL is example.com/language. I also tried {R:0} or {C:0} to get the top level but no effect. – Gforse Jan 18 '18 at 14:12
  • The action url in the first rule should have been "https://{R:1}", nothing more. Try activating Failed Request Tracing (docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/…) and look what happens with your rules. – Gerard H. Pille Jan 18 '18 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.