We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Subdomain Won't Redirect HTTP to HTTPSRSS

28 replies

Last post Apr 28, 2021 02:28 AM by haselbaink

  • Subdomain Won't Redirect HTTP to HTTPS

    Oct 29, 2020 11:31 AM|neuropathy|LINK

    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?

  • Lex Li
    Want to have a chat on the issues you meet? Book an appointment at https://buy.stripe.com/cN24ia0yi7sAdIA7sv
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 06:36 AM|Jalpa Panchal|LINK

    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.

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:06 AM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:09 AM|neuropathy|LINK

    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? 

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:15 AM|neuropathy|LINK

    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. ?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:20 AM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:24 AM|Jalpa Panchal|LINK

    Hi,

    What exactly you want to redirect? 

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:28 AM|neuropathy|LINK

    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? 

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 07:51 AM|Jalpa Panchal|LINK

    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:

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:10 PM|neuropathy|LINK

    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.

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:18 PM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:23 PM|neuropathy|LINK

    Serious problems here:

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:23 PM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:32 PM|neuropathy|LINK

    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. 

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 30, 2020 10:54 PM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Oct 31, 2020 07:43 PM|neuropathy|LINK

    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.

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 02, 2020 09:43 AM|Jalpa Panchal|LINK

    Hi,

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

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 03, 2020 09:33 AM|neuropathy|LINK

    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.

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 03, 2020 09:35 AM|Jalpa Panchal|LINK

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

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 03, 2020 07:54 PM|neuropathy|LINK

    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.

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 04, 2020 08:17 AM|Jalpa Panchal|LINK

    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.

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 05, 2020 09:37 AM|neuropathy|LINK

    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?

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 05, 2020 10:16 PM|lextm|LINK

    neuropathy

    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.

    Lex Li
    Want to have a chat on the issues you meet? Book an appointment at https://buy.stripe.com/cN24ia0yi7sAdIA7sv
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 06, 2020 07:50 AM|neuropathy|LINK

    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. 

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 06, 2020 08:19 AM|Jalpa Panchal|LINK

    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:

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 06, 2020 09:26 AM|neuropathy|LINK

    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. 

  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Nov 06, 2020 06:58 PM|lextm|LINK

    neuropathy

    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.

    neuropathy

    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.

    Lex Li
    Want to have a chat on the issues you meet? Book an appointment at https://buy.stripe.com/cN24ia0yi7sAdIA7sv
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Subdomain Won't Redirect HTTP to HTTPS

    Apr 28, 2021 02:28 AM|haselbaink|LINK

    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.