开发者

deploy web site on IIS 7 with and without www prefix

开发者 https://www.devze.com 2023-03-29 03:56 出处:网络
I want to deploy website on IIS 7 with www and also without www prefix. Do I need to create twoo web sites in IIS. e.g. www.something.com and someth开发者_StackOverflowing.com or is there another opti

I want to deploy website on IIS 7 with www and also without www prefix. Do I need to create twoo web sites in IIS. e.g. www.something.com and someth开发者_StackOverflowing.com or is there another option how can I do it only with one web site in IIS.

thanks


Create 1 website and add 2 host bindings. Using inetmgr, when you click on the website the bindings should be on the right side. You'd add two bindings with the same IP and different host name "www.host.com" and "host.com". You also need to make sure your DNS server has both host entries pointing to your websites IP.


The www prefix is just a DNS record, typically used as either an A record, or a CNAME record. The A record will cause DNS lookups to use the directly specified IP address. A CNAME (canonical name) will cause the DNS query to start over, using the value specified as the canonical name.

E.g.:

www.something.com A 65.42.3.152

... will resolve DNS queries directly to the IP address.

www.something.com CNAME something.com
something.com A 65.42.3.152

... will cause the DNS query to start again with something.com as the argument.

You will need to add both as bindings for your website, as IIS will try and resolve the host header value to match a site.

Obviously, if you add both www and the non-www version you do risk duplicate content when the site is being crawled. You can resolve this a variety of ways, you can either redirect to one or the other (e.g., redirect www.something.com to something.com) using URL rewriting (and a 301 response code), or you can specify a canonical tag:

<link rel="canonical" href="http://something.com" />

... etc. The downside to having the non-www as the website's main address is that any cookies will be for something.com domain, which means if you intend do any other subdomains (e.g. CDNs, perhaps static.something.com) you'll be transmitting cookies for all requests to anything.something.com as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消