can't access the site without WWW in the url
Solution 1
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.
Solution 2
There are a number of potential issues here, but the two most likely issues are probably:
-
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>
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.
Related videos on Youtube
Community
Updated on September 18, 2022Comments
-
Community over 1 year
Possible Duplicate:
Enable access without “www.” on UbuntuI 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!!!
-
Niklas B. over 12 yearsThis belongs to webmasters.SE or serverfault.SE (not sure which).
-
Eugene over 12 yearscan you show your vhosts.conf (apache)
-
Admin over 12 years@Evgeniy i afraid i can't , i got only access to DirectAdmin and Ftp server.
-
S19N over 12 yearsWhat does "doesn't work" stand for? What error do you see when looking for domain.com?
-
-
Ladadadada over 12 yearsIt's also normal, once you have both
domain.com
andwww.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.