Every website used to be like “www.example.com”. Now I rarely encounter this “www.”. Why did it even exist and where has it gone? I also used to run into websites with legitimate domains, but “ww1.” instead of “www.”, these were probably phishing sites, but how did this actually work on top of legitimate domains?

  • pulppanda@lemmy.world
    link
    fedilink
    arrow-up
    22
    ·
    2 days ago

    Hey something I can answer!

    TLDR: Because most owners of domains want their emails to have the same root (e.g.: bobby@acme.com as the email and acme.com as the website)

    TLDR word salad: RFC rules restricts root domain CNAME records from coexisting with other DNS record types. Early internet bypassed this by pointing the website to subdomain www.example.com with a CNAME record; while hosting MX record at the root example.com Modern dns services have CNAME flattening which dynamically responds to an A record query at the root example.com with multiple ips

    Also DNS is complicated


    Some of the comments here describe the results of what happened but do not touch on the reason behind why www was common and why it is not anymore

    The reason is very boring: because the rules say so. Specifically https://www.rfc-editor.org/info/rfc1034/ “If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its liases cannot be different.”


    To discuss this further we need to breakdown what is part of the url in the first place so we don’t mix things up. e.g. https://www.google.com/

    https --> specifies the protocol here its http encrypted over TLS (SSL if your old)

    : --> separates the protocol from the rest of the url

    // --> fun hold over https://archive.nytimes.com/bits.blogs.nytimes.com/2009/10/12/the-webs-inventor-regrets-one-small-thing

    www --> subdomain

    google.com --> root domain

    .com --> top level domain https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains


    Now for some common DNS address types you are probably already familiar with are

    A records (amazon.com translates to ipv4 98.87.170.71)

    AAAA records (google.com translates to ipv6 2607:f8b0:4004:c1f::71)

    MX record (tells where your email goes to)

    CNAME record (points to another DNS record name - usually an A record)


    So why does a domain restriction on CNAME interfere with a website?

    Because most owners of domains want their emails to have the same root.

    And the rules do not allow for the root domain name to have both a CNAME and a MX record

    For example, to have bob@amazon.com work.

    A top level MX record for amazon.com must be published.

    If an MX record for amazon.com exists CNAME can not exist.

    So in the early days of the internet, a compromise standard was made.

    MX records live at the root (eg: amazon.com) to direct mail for bob@amazon.com

    CNAME records live at www. subdomain (eg: www.amazon.com) to direct web traffic


    Why not just drop the CNAME at the root?

    Use MX for mail at the root and A record at the root for website!

    This will work perfectly fine actually. There’s nothing functionally wrong with this.

    In fact you can have your root A record round robin to several ips.

    So your traffic can be roughly distributed at the DNS level across a few computers.

    But this is generally a bad idea (without DNS health checks and other newer fancy things)

    Because the actual computer behind your ip will inevitably crash, or update, or die, or reboot.

    And now your website is fully down (1 ip) or partially down (1/3 of all traffic for example if you published 3 ips)


    Why use CNAMEs at all?

    Usually the CNAME record will point to some sort of load balancer. Think of this as router, it takes traffic in and sends it down to individual computers. If a computer dies, it takes it off from the available pool of computers; so that your traffic will hopefully live (session cache layer, etc, etc)

    So in the old days DNS looked like this

    MX record --> mail

    CNAME record --> A record load balancer ips --> fleet of computers with internal ips added and dropped by lb


    How does modern internet get on with root web traffic?

    Some smart people got tired of typing www all the time so they invented CNAME flattening (DNS flattening) The DNS service provider, will dynamically update, and serve a fleet of individual ips as A records to the root domain lookup.

    So now DNS looked like this

    MX record -> mail

    A record that keeps updating -> load balancer ips -> fleet of computers internal ips added and dropped by lb


    Isn’t that similar to old days? Why don’t I just update my A records myself in the old days? Wouldn’t that be the same?

    That’s actually exactly the same. The only problem with doing it yourself in the old days is DNS is hard.

    DNS is basically a globally distributed cache managed at different layers by different people.

    You COULD update the A records constantly yourself. You can even set your own record TTL to be 0 or 60seconds. However, random guy halfway across the world using budget ISP will not see your DNS update propagate to them for a few hours, sometimes 24 hours in worst case scenarios.

    Modern DNS service providers (cloudflare, aws route53, etc, etc) has their own DNS hosted nodes distributed across the world for you so they auto update the records constantly for you to ensure no stale DNS hits if possible.


    Practical Validation:

    Since DNS is public you can run some queries yourself to see how DNS is managed by large companies

    I’ll use amazon.com as example root MX record: https://mxtoolbox.com/SuperTool.aspx?action=mx%3Aamazon.com&run=toolpage

    --> this is what makes your mail work
    

    root A record: https://mxtoolbox.com/SuperTool.aspx?action=a%3Aamazon.com&run=toolpage

    --> this is CNAME flattening of the root
    
    --> note the 3 ips - these are the dynamic ips of the load balancer for the region mxtoolbox is running in
    

    root CNAME record: https://mxtoolbox.com/SuperTool.aspx?action=cname%3Aamazon.com&run=toolpage

    --> does not exist! because it can't. MX record already lives here
    

    subdomain CNAME record: https://mxtoolbox.com/SuperTool.aspx?action=cname%3Awww.amazon.com&run=toolpage

    --> this exists! to route traffic to the web server
    
    --> this is going to be some weird address <randomstring>-frontier.amazon.com this is some CDN that amazon uses to push traffic as close to the edge location where you are at to reduce page load times because physics exists
    
  • Kazumara@discuss.tchncs.de
    link
    fedilink
    arrow-up
    26
    ·
    3 days ago

    Back when people still hosted their own email and web pages and domain controllers etc, it was more common to break it out into subdomains. The www subdomain was for the web stuff that the webmaster would administer. Nowadays everything is outsourced, and you just point your main domain ar whatever webhosting company you’re using.

    But it was always possible to have a normal A record on your main domain and have a webserver listen to its port 80.

    I guess at some point everybody got so used to the world wide web just being there and every business being on it, that using the cool alliteration didn’t feel necessary anymore.

      • Flatfire@lemmy.ca
        link
        fedilink
        arrow-up
        4
        ·
        2 days ago

        Domain names are just human-readable addresses for a web server. An A record is just a pointer to the IP address of the web server a given domain name represents. It’s what domain name servers use to tell your browser where it actually needs to send your request.

      • Kazumara@discuss.tchncs.de
        link
        fedilink
        arrow-up
        3
        ·
        2 days ago

        The A record is the record in a DNS entry that contains the IPv4 address to which you wish to map the name in general.

        There are various others, for example the AAAA record is the one that contains the IPv6 address, the MX record is the one that contains the name of your mail server, the NS record contains the name of your nameserver, the SOA record has refresh timers and contact information for the zone admin, RRSIG records have cryptographic signatures proving authenticity of various other bits.

        Another interesting one in this context would be CNAME, there you can put the canonical name you’d like the user to look up instead of the one they were asking for. So you can leave out the A and AAAA, and put in a CNAME instead if you want to tell the user to look somewhere else.

        For example you can put in the DNS entry for www.example.com a CNAME record containing “example.com”. Now if a user comes asking for the A record of www.example.com, they will find the CNAME instead and know that they are supposed to look at the A record of example.com instead, because there isn’t a separate IPv4 address specifically for www.example.com.

  • nonentity@sh.itjust.works
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    3 days ago

    I’ve always made the ‘www.’ work for any site I’ve administered, but they immediately redirect with a 301 to the same url without it. It’s never been necessary, and I’ve always found it an eyesore.

    Start with reading the documentation that explains this config:

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1$1 [R=301,L]
    
  • Consti@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    4 days ago

    In addition to all the good answers, there also the case that most browsers just hide it nowadays. Go to google.com, you’ll see only that text in the URL field, the http(s)://www part is only shown when you click into the field, because as many have already said, it’s redundant in today’s infrastructure

  • heartSagan5@lemmy.zip
    link
    fedilink
    arrow-up
    5
    ·
    4 days ago

    It’s been “hidden” since Chrome v95 or something. Also, many companies might just host their web service on their main domain name.

    Also, hit Ctrl+Enter in any browser and it’ll tack that right on it and goto the webpage or hit a redirect or 5…whatever their architect setup.

    google.com may be a CNAME to www.google.com (for example).

    The www (or whatever hostname) is just to balance the web traffic from the other Internet services, like SMTP, POP3, IMAP, FTP, etc.

  • TubularTittyFrog@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    3
    ·
    edit-2
    4 days ago

    because it used to be necessarily, and it ICANN reformed stuff years ago, so now it’s not. it’s also why you can have all sorts of weird new suffixes you coudln’t before.

    you can look it up on the ICANN history website of web standards.

    • stoy@lemmy.zip
      link
      fedilink
      English
      arrow-up
      7
      ·
      4 days ago

      IT guy here, I can’t believe it was ever technically necessary, though I wouldn’t be surprised if it was a best practice published by ICANN.

      • AskewLord@piefed.social
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        edit-2
        4 days ago

        browsers didn’t auto-complete it like they do now, so it was necessary for users to type it when manually entering a URL.

        • Dultas@lemmy.world
          link
          fedilink
          arrow-up
          6
          ·
          4 days ago

          It was only necessary if the site was configured that way which most typically were. This was to differentiate which server would handle the request, web, file, mail, etc. I’m pretty sure there was no RFC that stated it was a requirement. Even on the early web it wasn’t uncommon to see a www2 or some other numbered prefix for different versions of a site. The reason you see it less now is because like you said browsers will add it, but also because most sites no longer use it as web is typically the assumed default.

        • Rhaedas@fedia.io
          link
          fedilink
          arrow-up
          2
          ·
          4 days ago

          I think before all browsers ended up filling it in, it was standard practice to set up the server to intercept anything missing that part before the domain name and stick a “www” in front so it wouldn’t just dead end. Basically a redirect.

  • marcos@lemmy.world
    link
    fedilink
    arrow-up
    2
    arrow-down
    9
    ·
    4 days ago

    That “www” is the name of the computer. It used to be that people liked to have a different computer just doing web stuff.

    Nowadays you don’t need to put the computer name on the address to send the web connections to it. But also, almost everybody hacks their network so that any computer can answer to any name they want. So people normalized not naming an specific computer to answer.

    • SpaceCowboy@lemmy.ca
      link
      fedilink
      arrow-up
      3
      ·
      4 days ago

      Well it’s a subdomain. You could have www.example.com and ftp.example.com go to the same computer, or you could have a load balancer direct www to multiple computers. But it’s helpful for keeping stuff organized in your configuration to give them different names based on what kind of content and/or protocol they’re serving out.

      Google does a pretty good job at this where it’s mail.google.com for gmail, www.google.com for their search, and if you’re logging into any google account, it’s something like accounts.google.com. That way you know which company you’re exchanging information with from the domain name, and the subdomain tells you which service you’re using. Helpful if you want to make sure it’s not a phishing site.