Domain doesn't work with "www.example.com" but does work "example.com"

Hello, I purchased a domain through cloudfare but for some reason when I try to share the domain with people they can't access it be clicking a hyper link"www.example.com" but can type "example.com" and hit enter and access the domain. When they click "www.example.com" it takes them to a safari page that says the server cannot be found. Please advise, thank you.

Mac mini, macOS 13.5

Posted on Sep 25, 2023 9:15 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 25, 2023 10:14 AM

www.example.com and example.com are two separate DNS names, for two separate servers. If you want the two names to resolve to the same host, you’ll need to have DNS translations for both names, and the www host will need to be redirected to not-www host.


Most registrars will have a subdomain creation facility somewhere in their DNS configuration portal.


Once you have the www subdomain created, you can then set up the desired forwarding.


Here is how to redirect a www.example.com virtual host on port 80 HTTP to the preferred example.com:80 host, assuming the Apache web server.


<VirtualHost *:80>
    ServerName www.example.com
    Redirect permanent / http://example.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName example.com
    # real server configuration
</VirtualHost>


If you don’t want to bother with that, you can also configure www.example.com and example.com to resolve to the same server, though you will still need to set up a virtual host for both names there, if you are using something like a web server with virtual hosting capabilities; with Apache, nginx, or otherwise.

4 replies
Question marked as Top-ranking reply

Sep 25, 2023 10:14 AM in response to 1234x

www.example.com and example.com are two separate DNS names, for two separate servers. If you want the two names to resolve to the same host, you’ll need to have DNS translations for both names, and the www host will need to be redirected to not-www host.


Most registrars will have a subdomain creation facility somewhere in their DNS configuration portal.


Once you have the www subdomain created, you can then set up the desired forwarding.


Here is how to redirect a www.example.com virtual host on port 80 HTTP to the preferred example.com:80 host, assuming the Apache web server.


<VirtualHost *:80>
    ServerName www.example.com
    Redirect permanent / http://example.com/
</VirtualHost>

<VirtualHost *:80>
    ServerName example.com
    # real server configuration
</VirtualHost>


If you don’t want to bother with that, you can also configure www.example.com and example.com to resolve to the same server, though you will still need to set up a virtual host for both names there, if you are using something like a web server with virtual hosting capabilities; with Apache, nginx, or otherwise.

Sep 25, 2023 10:00 AM in response to 1234x

Strictly speaking these are two different host addresses. For many domains, one points to the other automatically, in order to allow shortened addresses, but it has to be configured that way. The trick isn’t universal by itself. If that configuration hasn’t been done, then the two addresses will get different responses in browsers.

Talk to you hosting provider about synchronizing these two URLs.

Sep 25, 2023 10:26 AM in response to MrHoffman

thank you, I should haven mentioned that:

  1. Im using Cloudfare and that
  2. I have a Url forwarding for "example.com/*" to another web page lets call it "https://watches.com".
  3. The current CNAME is Name "example.com" and content "www.example.com" and is proxied
  4. There is another CNAME Name "sig1._domainkey" and content "sig1.dkim.example.com.at.icloudmailadmin.com" and is not proxied
  5. I purchased the domain through apple set up custom domain

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Domain doesn't work with "www.example.com" but does work "example.com"

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.