0
我的網站與http://example.com和http://www.example.com的行爲不同。我知道這些被認爲是兩個不同的領域。但我該如何解決這個問題?人們將主要輸入example.com而不是完整的網址,因此我應該怎麼做才能讓這兩個網址指向同一網站?如何配置域名的DNS記錄以指向兩個IP地址?
我的網站與http://example.com和http://www.example.com的行爲不同。我知道這些被認爲是兩個不同的領域。但我該如何解決這個問題?人們將主要輸入example.com而不是完整的網址,因此我應該怎麼做才能讓這兩個網址指向同一網站?如何配置域名的DNS記錄以指向兩個IP地址?
規則
<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>
這兩個域名都指向DNS中的同一個IP地址。看來我的代碼正在考慮這兩個域的不同。 – van
如果用戶輸入example.com,是否有方法將用戶重定向到www.example.com。 – van
是的,這是我在我的回答中提到的規則。 – khorvat