Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploy web site on IIS 7 with and without www prefix

Tags:

iis

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 something.com or is there another option how can I do it only with one web site in IIS.

thanks

like image 627
zosim Avatar asked Aug 18 '11 12:08

zosim


2 Answers

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.

like image 173
Louis Ricci Avatar answered Nov 15 '22 20:11

Louis Ricci


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.

like image 39
Matthew Abbott Avatar answered Nov 15 '22 19:11

Matthew Abbott