Gabriele Ottanelli
Gabriele Ottanelli

Reputation: 11

IIS hosted web application works fine with ssl without www, gives 404 error with www

Good morning. I have a web application (made with angular if useful) hosted with IIS on a windows server 2016 with certificate (made with Let's Encrypts wacs) that works fine with ssl. the problem is, if i use www the site not only appear as not safe, but also gives 404 error. I tried the following rule on web.config to redirect to non www but without success

<rule name="Redirect WWW to non-WWW" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^example\.com$" negate="true" />
      </conditions>
      <action type="Redirect" url="https://example.com/{R:1}" />
</rule> 

I have other rules, thats my complete webconfig file: https://pastebin.com/wRWarfCV

Upvotes: 0

Views: 680

Answers (1)

samwu
samwu

Reputation: 5195

I think https://www.example.com and https://example.com are Different domains. you need to reissue certificate and add http://example.com as primary domain and add other domain http://www.example.com.

More information you can refer to this link: How do I reissue my SSL certificate?.

Upvotes: 0

Related Questions