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.

Possible Duplicate:
Enable access without “www.” on Ubuntu

I just got set-up my first website and bought my own first domain name , but problem has showed up.

I noticed that i can enter my site only with WWW at first of the url , for example this will work WWW.DOMAIN.COM but this wouldn't DOMAIN.COM

what do i need to make it work? thank you in advance!!!

share|improve this question

migrated from stackoverflow.com Jan 3 '12 at 13:58

This question came from our site for professional and enthusiast programmers.

marked as duplicate by splattne Jan 3 '12 at 17:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
This belongs to webmasters.SE or serverfault.SE (not sure which). –  Niklas B. Jan 3 '12 at 13:52
    
can you show your vhosts.conf (apache) –  Evgeniy Jan 3 '12 at 13:52
    
@Evgeniy i afraid i can't , i got only access to DirectAdmin and Ftp server. –  Mor Sela Jan 3 '12 at 13:56
    
What does "doesn't work" stand for? What error do you see when looking for domain.com? –  S19N Jan 3 '12 at 14:03

4 Answers 4

There are a number of potential issues here, but the two most likely issues are probably:

  1. Apache configuration: Check your vhosts configuration and make sure that you have specified an alias for this domain. Something like:

    <VirtualHost *:80>
       ServerName yoursite.com
       ServerAlias www.yoursite.com
       DocumentRoot /path/to/root
       ErrorLog /path/to/logs/error.log
       CustomLog /path/to/logs/access.log combined
    </VirtualHost>
    
  2. DNS Configuration: Make sure that when you ping yoursite.com and www.yoursite.com that they are both pointing at the same server. It's possible that your DNS configuration is pointing the www subdomain at a different server.

share|improve this answer

There are two major considerations here: DNS, and virtual host configuration.

DNS is the system by which computers resolve names to IP addresses to determine which network computer a name refers to. www.domain.com is technically a subdomain of domain.com (although it is rarely treated as such) and can resolve to a different IP address to the root of the domain. The usual approach to this is to create a CNAME (alias) record for www.domain.com that points to domain.com. This means that if your server's IP address changes, you only need to update the A record for the root of the domain, and www. will follow suit. Your host/domain registrar should have provided you with a control panel that will allow you to modify the DNS records for your domain - if they have not, or you are unsure how to do this, you should contact your hosting company for assistance.

Virtual Hosting is a system that allows one server to be responsible for services provided by more than one domain. Shared hosting environments use this kind of system. In order for it to work, the server needs to be told which domains it is responsible for. The approaches to this are many and varied, but the key point is that since the root of the domain and www. are technically different, the server will need to be told that they actually refer to the same resource. This would likely be the responsibility of your hosting company to ensure that the proper configuration is in place, and if your DNS is properly configured but you are still having a problem, you should contact them to have them check the configuration.

share|improve this answer
    
It's also normal, once you have both domain.com and www.domain.com working, to configure your web server to redirect one to the other. Questions on how to do that have already been asked here. –  Ladadadada Jan 3 '12 at 15:06

If you have access to the php.ini file it can be changed there but I'm guessing you don't. An alternative is to create a file called .htaccess and place it in the root directory of your website. Add this to the file:

Options +FollowSymLinks 
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC] 
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]

Of course, change "yoursite.com" to your actual domain name.

share|improve this answer

You should look if the root directory of your code is www. If so I suggest you do the following: 1. Move all your code ( from www ) up one lever (let's say that you have /trunk/www, so move your code to trunk). 2. replace the www directory with a shortcut called www to the "trunk" directory.

if this doesn't work you should look at htaccess so you can redirect the call for DOMAIN.COM to WWW.DOMAIN.COM.

Hope this helps, Regards, Alex

share|improve this answer