Home >Technology peripherals >It Industry >Your Domain Name: Do You www or Not?

Your Domain Name: Do You www or Not?

Christopher Nolan
Christopher NolanOriginal
2025-02-17 09:12:11158browse

Your Domain Name: Do You www or Not?

Core points

  • Although the "www" prefix is ​​technically accurate and avoids confusion with similar URLs for other protocols, it is no longer necessary in the modern era. Most people understand that .com, .org, or .net addresses are websites, even if they do not have the "www" prefix.
  • Whether to use "www" is usually determined by aesthetic preference and typing convenience. However, be sure to make sure both the "www" version and the non-"www" version of your domain are accessible, as users may enter either version. This can be achieved through simple web server configuration settings.
  • Once you decide to use or not use "www", you must stick to it. Switching between the two can cause search engine indexing and user access issues. If a switch is made, a 301 redirect should be used so that the search engine updates its index accordingly.

This article is part of a series of articles created in collaboration with SiteGround. Thank you for supporting the partners who made SitePoint possible.

In the early days of the Internet, it was crucial to publish your URL with the "www" prefix. These three characters avoid confusion; more obviously you are referring to a network domain name. But, in 2017, is “www” still necessary? The network is growing rapidly, and few organizations choose to use "www" in front of their URLs. People understand Google.com, Facebook.com, Twitter.com and SitePoint.com are websites. Top-level domains (TLDs) starting with ".", such as ".com", make this even more obvious, but even without it, the network is usually the first choice for anyone looking for a company or service.

Reasons to use "www"

The "www" prefix has not been deprecated yet. It is clear, technically accurate, and can distinguish addresses from similar URLs in protocols such as mail or FTP. While website addresses can be identified from their .com or country-specific domain suffixes, hundreds of top-level domain options have been introduced over the past few years. If you are using a TLD that is not too easily recognizable or vague, such as mysite.ninja, adding "www" will help avoid any doubts. If there is no "www", you must point the root (non-www) domain name DNS A record to the IP address of your web server. This can be too strict if you experience availability or performance issues; A records are fixed and the spread of changes can take a day or two. The "www" subdomain can be configured using a DNS CNAME record, which can be updated and changed immediately. You also need to pay attention to cookies and client storage. The cookie, sessionStorage, or localStorage values ​​set for non-www domain names are shared in all subdomains. If your main website - mysite.com - sets 10Kb of cookie data, it will be transferred in every request and response from app.mysite.com, regardless of whether the app uses that data. Finally, the "www" prefix is ​​crucial for applications such as email clients and word processors that convert text into links.

Reasons for not using "www"

Despite the technical issues mentioned above, using non-www domains rarely becomes a problem unless you have complex hosting or application requirements. The root address is easier to read, easier to type, and easier to adapt to a smaller (mobile) browser interface. This address is more likely to be used in your next tweet without using a URL shortener. Few people will be confused – especially if many people use Google search boxes instead of browser address bars.

This is mainly a vanity issue

Some domains look better and more balanced when using "www", for example:

  • www.google.com
  • www.facebook.com
  • www.bbc.co.uk

Some domains look better without using "www":

  • twitter.com
  • yahoo.com
  • wikipedia.org

Some domains seem to work well in both directions:

  • sitepoint.com / www.sitepoint.com
  • amazon.com / www.amazon.com
  • dropbox.com / www.dropbox.com

Select any one that suits your domain name, but...

Configure it wisely

The user may or may not add "www", so make sure both www and non-www addresses work properly when the browser makes a request. This can be done in a number of ways, but the easiest option is probably the web server configuration settings. The following code configures Apache to redirect all non-www requests to the www version of the URL. Add it to the .htaccess file in the web root directory:

<code>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/ [R=301,L]</code>

Alternatively, this .htaccess redirects all www requests to non-www URLs:

<code>RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]</code>

This allows you to promote the "www" domain name in a document or email even if you don't need it. If you provide services via secure HTTPS, you should also be cautious. SSL certificates are usually valid for non-www and www domain names, but cannot be guaranteed. Please consult your certificate authority – if you have the wrong certificate, you may need to purchase additional or wildcard certificates. Some hosting providers, such as our partner SiteGround, allow you to order an SSL certificate that can be used in your domain name or not with the www prefix. Finally, make a decision and stick with it. Never switch between non-www and www URLs on a whim! The above .htaccess code emits the 301 Moved Permanently HTTP redirect code so that the browser and search engines can update their index accordingly. The propagation of changes may take some time; during this time, users may experience access problems. Has your company chosen to use or delete "www"? Have you succeeded? Has anyone noticed it? !

FAQs about domain names (FAQ)

What is the difference between a domain name with www and without www?

The difference between a domain name with www and without www is mainly due to its appearance. www is a subdomain that is traditionally used to indicate that a site is part of the network, not other parts of the internet, such as FTP or Gopher. However, in modern usage, it is largely unnecessary and many websites choose to omit it. Technically, domain names with and without www are considered separate entities by search engines, so one must be redirected to the other to avoid duplicate content issues.

How to configure my website so that it can and does not use www?

To make your website available and not use www, you need to set up a DNS record for both versions of the domain name. This can usually be done through the control panel of your domain registrar or hosting provider. You should also set up a 301 redirect from one version to another to make sure that search engines index only one version of your website.

Why can't my website work without using www?

If your website does not work without www, it may be because you do not set up a DNS record for the non-www version of the domain name. You need to create an A record for the domain name without www, pointing to the IP address of your web server. This can usually be done through the control panel of your domain registrar or hosting provider.

Can I use a domain name without www in Cloudflare?

Yes, you can use domain names without www in Cloudflare. You just need to add DNS records for non-www versions of the domain name in the Cloudflare dashboard. You should also set up a page rule that redirects www traffic to a non-www version of your website to ensure that all visitors end up at the same location.

What is a .no domain name?

.no domain name is a Norwegian country code top-level domain (ccTLD). It is used by websites targeting Norwegian audiences. Like other ccTLDs, it can or does not work with the www prefix.

How to redirect www to non-www in my .htaccess file?

To redirect www to non-www in the .htaccess file, you can use simple rewrite rules. Here is an example:

<code>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/ [R=301,L]</code>

This rule redirects all traffic from www.yourdomain.com to yourdomain.com.

From the SEO perspective, is it better to use www or not?

From the SEO perspective, it doesn't matter whether you use www or non-www. It is important to choose a version and stick with it to avoid duplicate content issues. You should also make sure to set your preferred domain name in Google Search Console.

Can I switch from www to non-www without affecting my SEO?

Yes, you can switch from www to non-www without affecting your SEO, as long as you set it from the old version to the new version of the 301 redirect. This will ensure that any linked juices from the old version are passed to the new version.

Why do some websites still use www?

Some sites still use www for historical reasons, or because they have subdomains and want to keep their URL structure consistent. However, this is mainly a matter of personal preference, and there is no technical reason to use www in modern web development.

Can I use a domain name without www in WordPress?

Yes, you can use domain names without www in WordPress. You just need to set the WordPress address and site address to the non-www version of the domain name in your WordPress settings. You should also set up a 301 redirect from www version to non-www version to ensure that all visitors end up at the same location.

The above is the detailed content of Your Domain Name: Do You www or Not?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn