Historical background Although people often confuse the terms "domain name" and "host name", there is a difference between them, and it's not just a semantic difference. I'll briefly explain the two terms to show the difference: As an IT administrator, your network system is your domain. You need to name this domain and register it in the Domain Name System (DNS). For example, you can name it "example.com". Under the domain is the host, and each networked device can be counted as a host.
In your domain, machines that serve World Wide Web (WWW) files automatically get the host name "www", so your fully qualified domain name (FQDN, a name with both host name and domain name) is www.example.com. Regardless of whether other hosts have web servers, the names of other hosts in the domain will also be changed to include "www", which makes it easier to manage hosts in the network system. To use a web server in the domain "example.com", you need to use a host named www.example.com. BTW: In the early days of the Internet, there was no such thing as virtual hosting. All web servers had to serve the same website (or at least the same IP address). It didn't matter what the hostname was, as long as it pointed to the correct IP address. "Naked domain names", that is, domain names without "www", such as "example.com", are called "origin domain names" in the DNS protocol. In the mid-1990s, as the World Wide Web became more and more popular, some administrators began to point the root domain name to the same IP address as the web server host. In this way, web page visitors only need to enter "example.com" in the browser to access it, instead of entering the full host name "www.example.com". Then, SEO came along Starting from the root domain name "example.com" and the host name "www.example.com" can point to different IP addresses, after January 1997, they can also point to different web pages under the same IP address. People who know something about Search Engine Optimization (SEO) began to tell us that we must choose a canonical host name, and the other name must also point to this canonical host name and use the HTTP 301 response code. This also makes sense, but which one should I choose? If you only consider SEO, it doesn’t matter which one you choose. But there are many issues beyond SEO, which I will continue to explain below. People's understanding of URLs In the early 2000s, I worked at a marketing agency and there was a concern that if we omitted the "www" in a URL, people might not realize it was a World Wide Web address. At the time, omitting http:// from URLs was relatively new. Also, due to some legacy issues, I personally prefer to use the full "proper" hostname, which is "www.example.com". Now it's very different. If you have a common top-level domain, everyone will understand whether you have www or not. Also, a version of a name can now be redirected to another address. So if your canonical hostname is "www.example. com" and you use the cleaner-looking "example.com" in print ads, that's fine. However, if you have a newer top-level domain, like .beer, it's better to include www because people may not recognize it as a web address. Without www, it looks better and more concise I have to admit: "example.com" is shorter and easier to pronounce. Try to pronounce "www" in one breath, right? And without the www, the name takes up less space. So it's understandable that people started omitting the "www" and using the root domain name as the hostname. So why are you still struggling with whether to add www? Why are we still arguing about this? Can't people just use whatever they like? sure. However, if you are a website administrator, you may want to think carefully before deciding, because most things on the Internet, such as cookies, are used without much thought. The cookie is sent to all subdomains Cookies set on a hostname are also sent to all subdomains, that is, if a cookie is set on a website at "example.com", the browser will also send this cookie when browsing to "www.example.com". This sounds like a good thing, since they’re the same website anyway, right? However, this cookie will also be sent to “cdn.example.com,” “email.example.com,” “intranet.example.com,” and any other third-party service that contains “.example.com.” Many third-party service websites share your cookies this way. Cookies set under "www.example.com" are not sent to these sites. Your browser recognizes that they are not "sub-services" but completely different services, so no cookies are sent. Unnecessary cookies slow down the performance of web pages. Every time you visit a web server, the browser will send HTTP and cookies. Therefore, if your cookie is set under the root domain "example.com", then every time you visit "email.example.com" or "intranet.example.com", the browser will send the cookie. This will cause the web page to run slower and affect the user experience. Third parties can read cookies So, if your hostname is the root domain ("example.com"), and you can log into a content management system (CMS), the CMS will send a cookie to your browser while you are logged in. Then, if you visit "someinternalservice.example.com" (an internal service), the administrator of that site can access and use this cookie to log you into "example.com" in the CMS. Similarly, when you visit "email.example.com" (email), your CDN service provider can also log in to your email service and load a large number of websites containing "example.com", such as "static.example.com" and so on. If you are concerned about the security of the content on your website, you should use a hostname with the www prefix. If this doesn't make you decide whether to use a prefix or not, then I can't help you. Neither HTTPS nor two-factor authentication (2FA) can ensure the security of your website, although 2FA is usually useful, but security measures such as IP restrictions can help. Subdomain cookies can be shared across the entire domain If you have a service on a subdomain such as "sso.example.com", RFC 6265 enables you to set a cookie on the subdomain and share it with "example.com" or "www.example.com". Therefore, using a prefixed hostname allows for greater flexibility. The DNS root domain name cannot be a CNAME (canonical name) Speaking of flexibility, we have to talk about DNS again. There is a restriction in DNS that the record type of the root domain name must be A, which means it must point to a fixed IP address. When your site grows, you may want to switch it to a hosting service, or point it to a web application firewall or DDoS mitigation service. At this time, you can use a CNAME record to point your hostname to another flexible hostname. This new hostname is selected and managed by the hosting provider based on your traffic and needs. If your hostname is at the root of the domain ("example.com"), you can't use CNAME. However, hostnames with a prefix don't have this problem. Therefore, if you want to have more options, you should use a hostname with www from the beginning. Conclusion: Let’s add www There is a difference between using www and not using www. Without www, the root domain name does look simpler, but this only makes the browser search bar simpler. You can use "www.example.com" as the host name and use the name without www everywhere else, because even if the user enters the name without www, the browser will automatically jump to the correct page. There are many advantages to using the full name with www as the host name: the web page runs optimally, is safe and reliable, and is very flexible. This should put an end to this debate: add www! |
>>: What have the three major operators done to prevent and control the epidemic?
TMThosting has launched the Dedicated Server &...
Just a few days ago, the plenary session of the i...
Kvmla has launched a year-end and 2024 New Year p...
"No one needs 6G. The industry should make 6...
[[373761]] With the development of new generation...
The Fourth Industrial Revolution will see the lin...
HostKvm recently launched a new VPS host in Europ...
[[380257]] The block diagram of the STM32 network...
The foundation for seamless 5G implementation 5G ...
Docker provides a variety of network drivers, all...
Zigbee is a widely used smart home protocol that’...
When it comes to network cabling, outdoor connect...
In June this year, protesters held signs such as ...
Telecommunications company Ericsson has released ...
【51CTO.com original article】 Do you know how much...