Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Why does my website not load if I type:

example.com

But it does work when I type:

www.example.com

Is this a setting in IIS?

We are using ASP.NET 3.5 with a SQL Server database.

Thanks in advanced!

share|improve this question

5 Answers 5

up vote 3 down vote accepted

Even if you have the DNS records for example.com and www.example.com pointing to the web server, you must still tell IIS7 which site to serve up when it sees these domains.

This is acheived through adding a "Binding" for each domain name (called a Host Header) to tell IIS which "site" to serve up to the client.

You will need a binding for "www.example.com" and a binding for "example.com".

See a picture here: http://www.iishacks.com/wp-content/uploads/2008/10/host-header-iis7.gif

share|improve this answer
    
You can see a text description here, too: technet.microsoft.com/en-us/library/cc731692%28WS.10%29.aspx –  Kenny Mar 5 '10 at 11:59

What you need is having tool for URL rewrite to check if URL was put as http://domain.com, if so - add www. inside. For this things you'll need additional software for redirect. Me myself was using ISAPI_Rewrite tool for simple things like rewrite, also this software can be provided free. Now I'm using Helicon Ape as an Apache emulator for IIS7.

share|improve this answer

Typically you have to actually add a DNS record for example.com to your DNS in order for your site to be accessible at both example.com and www.example.com - if both of these records already exist in the DNS then it's probably an IIS setting somewhere

share|improve this answer

Kenny's solution is probably the simplest. But if your web pages or application code depend on the url being www.example.com, they won't work properly.

A different solution is to set up a new site for example.com in IIS and use an http redirect to refer requests to www.example.com. Your users' sessions will continue on www.example.com, and all your site code will work as normal.

share|improve this answer

In apache I would add www.example.com as an alias to example.com and done.
I suppose in IIS should be the same principle...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.