简体   繁体   中英

How to configure the DNS record for a domain name to point both at the same IP address?

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?

  • 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM