My website behaves differently with http://example.com and http://www.example.com. I know these are considered as two different domains. But what do I do to fix this issue? People will mostly type example.com instead of the full url, therefore what should I do so that the two urls' point to the same website?
1 Answers
0
votes
- First thing that you need to do is to make sure that DNS server has records for both of those domains pointing to the same server (A records).
- You need to add bindings for those two addresses to point to the same web application in the web server settings (In case of IIS you will need to add multiple bindings on Edit Site menu)
- In case you need to redirect HTTP to HTTPS you can use IIS rewrite module with the following rule
Rule
<rule name="RedirectToWWW" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern=".*your-domain\.com" />
<add input="{HTTP_HOST}" negate="true" pattern="www\.your-domain\.com" />
</conditions>
<action type="Redirect" url="https://www.your-domain.com/{R:1}" redirectType="Permanent"/>
</rule>