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.

What is the setting I need to do to make the website work as domainname.com and www.domainname.com

Thanks Jean

share|improve this question

migrated from superuser.com Jun 17 '10 at 16:03

This question came from our site for computer enthusiasts and power users.

add comment

4 Answers 4

You need to add a www DNS record. I would read this article.

share|improve this answer
    
+ eventually routing the request to the same folder / document-root –  akira Jun 17 '10 at 14:44
add comment

Using example.com as an example:

  1. Insert A records for www.example.com and for example.com in your DNS configuration, both to contain the IP address of your web server

  2. Configure your web server to redirect example.com to www.example.com.

The latter is preferable to just having both sites serve the same document root, because then cookies will work more reliably.

share|improve this answer
3  
Somewhat off topic, but 2. is not exactly trivial when you have an https canonical url and want to avoid certificate errors. –  mika Jun 21 '10 at 7:50
add comment

The best practices way to do this in most cases is 2 DNS records. One 'A' Record for the root (example.com) and one CNAME for the www prefix (www.example.com).

The only time you would use a redirect would be if you wanted force the URL to always display one address (i.e. always show www.example.com even if they type in just example.com or vice versa)

share|improve this answer
add comment

Read the following site for detail on CNAME.

http://www.zytrax.com/books/dns/ch8/cname.html

share|improve this answer
add comment

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.