locked
Subdomain Won't Redirect HTTP to HTTPS RRS feed

  • Question

  • User-1509307234 posted

    Hi, 

    I'm using Server 2016 with IIS 8. I can't figure out what I'm doing wrong here. I've followed this guide: 

    https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https

    I made sure to try both options for Redirect Rule - https://{HTTP_HOST}{REQUEST_URI} and https://{HTTP_HOST}/{R:1}

    I checked the web.config file and found the code - I believe this is automatically added when creating these rules in IIS?

    I disabled one rule to try the other - can't figure this out. I tried restarting the site and the server. 

    The site is a subdomain, which might be part of the issue? 

    http://orderform.supermoss.com - I'm trying to redirect to https://orderform.supermoss.com automatically. 

    Does anyone know what I'm doing wrong here? 

    These are the rules from Web.config, which I've tried one at a time by disabling the rules before trying another:

     <rule name="HTTP to HTTPS Redirect" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTPS}" pattern="^OFF$" />
                        </conditions>
                        <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
                    </rule>


    <rule name="HTTP to HTTP Redirect - 02" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions>

    <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

    <rule name="HTTPS force" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
     <add input="{HTTPS}" pattern="^OFF$" />
     </conditions>
     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
     </rule>

    Does anyone have any ideas what's wrong?

    Thursday, October 29, 2020 11:31 AM

All replies

  • User-848649084 posted

    HI,

    Make sure you set the rule on the correct website. check your site binding detail. make sure the require SSL check box is unchecked.

    Friday, October 30, 2020 6:36 AM
  • User-1509307234 posted

    Hello, thank you for the suggestion, but I'm confused about this... the site needs to use SSL, but I still need to disabled SSL here? I've tried and restarted the site and the server in IIS... still nothing. It's a subdomain. I cannot figure this out...

    Does it take a while or is it immediate, if it's successful? Do I need to restart the server and site? Both, or only one or the other?

    Friday, October 30, 2020 7:06 AM
  • User-1509307234 posted

    Is there anything specific I need to do to get all the possible addresses someone might enter to redirect to HTTPS? 

    Possibilities: 

    sub.domain.com

    http://sub.domain.com

    http://www.sub.domain.com

     

    Or do I only need to deal with one? Which one? 

    Friday, October 30, 2020 7:09 AM
  • User-1509307234 posted

    I might have spoke to soon... maybe it's working after disabling the SSL requirement? 

    Can someone verify that it's working properly? I can't tell if my browser (even private mode) is dealing with this properly. It seems that private mode still retains site info... 

    orderform.supermoss.com

    http://orderform.supermoss.com - this should automatically redirect to HTTPS://orderform.supermoss.com

    Do I need to do anything for www.orderform.supermoss.com or http://www.orderform.supermoss.com etc. ?

    Friday, October 30, 2020 7:15 AM
  • User-1509307234 posted

    In this image:

    https://pasteboard.co/Jy0oVuD.png

    Both of the HTTPS bindings have the SSL certificate referenced in them - but one doesn't have the site name? Should I remove one or the other? Should I remote the HTTP binding?

    Friday, October 30, 2020 7:20 AM
  • User-848649084 posted

    Hi,

    What exactly you want to redirect? 

    Friday, October 30, 2020 7:24 AM
  • User-1509307234 posted

    I want people to ONLY get HTTPS. I can't use a regular HTTP here. I want this to happen: 

    You enter "orderform.supermoss.com" in your address bar

    You get to HTTPS://orderform.supermoss.com

    Even if you enter www.orderform.supermoss.com or http://orderform.supermoss.com or http://www.orderform.supermoss.com

    I want it to go to HTTPS://orderform.supermoss.com

    Do I need to keep or change back the setting you suggested? 

    Friday, October 30, 2020 7:28 AM
  • User-848649084 posted

    for that first, make sure you have site  HTTP binding for orderform.supermoss.com and www.orderform.supermoss.com.

    add below rule:

    <rule name="https force" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTPS}" pattern="off" />
                        </conditions>
                        <action type="Redirect" url="https://orderform.supermoss.com/{R:1}" />
                    </rule>

    SSL setting:

    below is the result:

    Friday, October 30, 2020 7:51 AM
  • User-1509307234 posted

    Thanks for your reply

    Should I set IP Address to 1 or to * ?

    Should I delete the HTTPS binding I have that had no hostname? 

    Should I set the other bindings to have IP Address 1 instead of * ? 

    Is there a way to upload images in this forum while entering a reply? I entered this image by uploading it elsewhere and pasting a direct link to the image.

    Friday, October 30, 2020 10:10 PM
  • User-1509307234 posted

    Now it doesn't redirect AND it gives a 500 error when I try to access this subdomain using HTTPS: https://orderform.supermoss.com

    When I do this, do I need to restart the website and and the web server in IIS? Only restart website? Only restart web server? Both?

    Something went very wrong here.

    Note: I did NOT change bindings IP Address from * to 1 - do I need to do this?

    Friday, October 30, 2020 10:18 PM
  • User-1509307234 posted

    Serious problems here:

    Friday, October 30, 2020 10:23 PM
  • User-1509307234 posted

    Note that I did NOT change the binding IP Address from * to 1

    Do I need to do this? 

    Do I need to restart the site and server in IIS? Just the site? Just the server? Both?

    Friday, October 30, 2020 10:23 PM
  • User-1509307234 posted

    IIS was saying "unable to retrieve rules" and had problems with URL Rewrite when I added that code in Web.config - I removed that code and the site is accessible by manually entering HTTPS://orderform.supermoss - still no redirection. I tried entering the rule from that other example in that site linked in the first post - not working. 

    Friday, October 30, 2020 10:32 PM
  • User-1509307234 posted

    Thanks for your response. Unfortunately I didn't get far with this. 

    I tried to put article.aspx in the inetpub/wwwroot as well as the actual subfolder of inetpub/wwwroot/ that has the Web.config file for this site. I have a folder called OrderFormV2 that's where Web.config for this lives - I know this since when I right-click on the site itself in IIS and select Explore, that's where I end up. 

    When I tried to go to http://localhost/article.aspx - it automatically tries to go to HTTPS and it gives a 404 not found error.

    I also tried to put article.aspx in the subfolder - inetpub/wwwroot/OrderFormV2 - same 404 not found and automatically tries to go to HTTPS - https://localhost/OrderFormV2/article.aspx

    I feel that all the trouble here is because this is a SUB DOMAIN - orderform.supermoss.com - Does anyone have experience with this?

    Friday, October 30, 2020 10:54 PM
  • User-1509307234 posted

    I removed the code that was suggested since that didn't work and it even caused the server to have a problem - 500 error

    It is OK again, but I'm back to the beginning - no redirect. 

    Is this because it's a subdomain? Older IIS - IIS 8? Binding problem? 

    I think that "All" is the right choice for IP Address in bindings, since "1" as given in the suggestion doesn't seem be appropriate.

    Does anyone have a true mastery of this who knows what needs to be done here? This isn't working. I have tried everything I can think of.

    Saturday, October 31, 2020 7:43 PM
  • User-848649084 posted

    Hi,

    In ip address you need to bind your machine IP address. 

    Monday, November 2, 2020 9:43 AM
  • User-1509307234 posted

    Hi, I tried to enter both the IP of the HTTP and the HTTPS instead of "All Unassigned"... both made the site unreachable. 

    I don't know what to try next. The other person's suggestion to create some kind of tracing also didn't work.

    Tuesday, November 3, 2020 9:33 AM
  • User-848649084 posted

    did you configure your domain name in the host file with IP address? 

    Tuesday, November 3, 2020 9:35 AM
  • User-1509307234 posted

    I don't think so. I'm taking over for someone else who created this site using Windows Server 2012 and IIS 8, so I don't know exactly what they've done. 

    I suppose I can check by looking at the hosts file on this server? What should the entry look like? Do I need to configure for HTTP and HTTPS? When I ping the addresses for each HTTP://orderform.supermoss.com and HTTPS://orderform.supermoss.com  they show different IP addresses... I'm not sure which to use, or both.

    Tuesday, November 3, 2020 7:54 PM
  • User-848649084 posted

    you have to configure your ipv4 address with a domain name in the host file which is located at c:\Windows\System32\Drivers\etc\hosts then use the domain name binding as mentioned in the previous post.

    Wednesday, November 4, 2020 8:17 AM
  • User-1509307234 posted

    What should the entry look like? Do I need to configure for HTTP and HTTPS? 

    I added - 23.217.138.109 orderform.supermoss.com

    And I tried ipconfig /flushdns 

    What are the exact bindings? Why don't you try to ping the subdomain and see what you get.

    Nothing is working and all of these suggestions just crash the site with 500 errors or just make it unreachable, which is even worse than before. 

    Does anyone actually know how to do this properly?

    Thursday, November 5, 2020 9:37 AM
  • User690216013 posted

    Does anyone actually know how to do this properly?

    1. Find a clean machine with nothing at all on IIS so that you can start from scratch.
    2. Set up a simple site (only static HTML pages) with both HTTP and HTTPS bindings.
    3. Set up the rewrite rule(s) to redirect from HTTP to HTTPS.

    The goals of above is to show you how simple it is to set up needed parts, and then you can go back to your complex site to perform the same.

    Always expect errors (including 500) as such redirection, though harmless by nature, can break web applications if those apps were developed without URL rewriting in mind. But since you know the redirection steps work for static pages you now how to chase the developers for bug fixes.

    Thursday, November 5, 2020 10:16 PM
  • User-1509307234 posted

    Is my site complex? It's a simple form on a subdomain.

    Do I need to upgrade IIS to get this working better? This is IIS 8 in Server 2012.

    Is this just hopeless? Bugs? Should I run this form in another way rather than with a subdomain? Would it be more likely to work if this were simply on it's own domain?

    This might be funny to others, but this isn't a joke to me. I'd appreciate realistic solutions. 

    Friday, November 6, 2020 7:50 AM
  • User-848649084 posted

    Hi,

    In the host file the entry will look like below:

    192.168.6.52 domian.com

    Note 192.168.6.52 will be your machine IP and domain you can select any domain.

    by using this method you can only access it on your machine. the host file is only for the machine in which you are accessing the site.

    disable the URL rewrite rule and clear browser cache and try to first bind the site with the domain. and you do not need to bind HTTP and https in the host file.

    below is my host file:

    because of security reasons, I hide my IP address.

    this is how my site binding looks like:

    Friday, November 6, 2020 8:19 AM
  • User-1509307234 posted

    Hi, 

    Should I update IIS? It asks to do some kind of update or get new modules when I first open IIS. This is IIS 8 in Server 2012. 

    I want to know if I need to do this before trying everything again. 

    Friday, November 6, 2020 9:26 AM
  • User690216013 posted

    Is my site complex? It's a simple form on a subdomain.

    Any site can be complex if the responses are dynamic (generated by a web framework like ASP.NET). The complexity can easily go beyond your imagination, and old frameworks like ASP.NET WebForms works pretty bad with URL rewriting.

    I'd appreciate realistic solutions.

    I bet no one posted in this thread expects you appreciate the efforts. The solutions are proposed, but your web apps can simply fail them.

    I have helped many clients on their rewriting rules and different variations are required as their web apps simply require such customization, or errors happen.

    Hire a consultant or open a support case via http://support.microsoft.com if you can.

    Friday, November 6, 2020 6:58 PM
  • User1840793565 posted

    A good curriculum vitae is an ability that can be difficult to master by itself. As a result, I can confirm that you should know the details. I can suggest reading a write my cover letter for me as it helped me build up a cool curriculum vitae that masked my shortcomings and enhanced my powers. So I am thankful I could find a good curriculum vitae here, and that these guys could help me.

    Wednesday, April 28, 2021 2:28 AM