Make sure your website works with or without www

Being a little lazy at times, I tend to skip typing “www.” before the domain name when I enter a URL in my web browser. No, it doesn’t save me a whole lot of typing, but bear with me here. Most of the time it works fine and I end up on the site I expect.

But it really surprises me how often typing in a domain name without “www.” in front results in one of the following:

  • My browser displays an error message such as “Safari can’t open the page “http://example.com/” because it can’t find the server “example.com”.”
  • My browser finds a server but nothing happens because there is no website configured.
  • I am redirected to a parked domain.
  • I get a “Directory listing denied” message.

This happens with all sorts of organisations, from the tiniest single-page websites to huge online presences of multi-national corporations.

You can add “www.” in front of the domain name and all is fine. But should you really have to do that? What I think should happen is that the web server either responds on the address I entered or redirects me to the www host. Unlike the no-www and yes-www folks I’m “www-agnostic” in that I don’t really care if the preferred host is the bare domain name or “www.” + domain name. Just make both work and redirect all traffic to one of them, I don’t care which. I do however think that it makes a really bad impression when any of the above happens when you try to access an organisation’s website without typing “www.”.

I’m no DNS or web hosting expert, so there may well be technical reasons that I am unaware of that make it hard or impossible to configure all web servers to work with or without the “www.”. But when this sort of thing has happened to clients, it usually turns out that whoever is hosting the site has simply forgotten about it.

Considering how many use their bare domain name in advertising, and looking at colleagues and relatives, I know I’m far from the only one who skips “www.” when manually typing in a URL. And do you really want to risk your clients losing visitors due to a misconfigured web server? I thought not, so remember to check this with the persons or companies responsible for the servers your clients’ sites are hosted on.

Posted on February 12, 2008 in Usability

Comments

  1. Hi,

    I agree with you.

    Removes the www before ennixo.com.

    However, to keep more time in Safari, type the name of the site (ie: 456bereastreet) and the press Alt+Enter. On Firefox and IE on Windows, press Ctrl+Enter.

    Hope this helps.

  2. February 12, 2008 by Roy Tomeij

    If you do make your website accessible with and without www, make sure that you use one as your “main” solution. For instance, if people go to “without www”, redirect them to “with www” (or vice versa). This way you won’t run into cookie trouble for instance, with people having a cookie on www, returning the next day to without www and finding their cookie is gone (for cookies, these are two different domains). I’m not sure about this, but doesn’t Google see with www and without www as two seperate domains, and thus considers it duplicate content? If so, the redirect should be a 301.

  3. I leave off the www almost all of the time and it annoys the crap out of me when I get a “no site configured for this address” error from a server.

    I guess I’m lazy, too, but for most of the sites that I visit, it’s unnecessary and almost never noticed. However, that one time it doesn’t work, it just infuriates me.

  4. Hi,

    I totally agree with you Roger!

    Hope some admins will read your post and change their config.

    Thanks

  5. Great post. I agree completely, and it’s worthwhile to point out that canonical URIs are not only relevant when it comes to www vs. no www.

    There should always, always, always be only one URI for any given resource. For example:

    • http://somedomain.com/photos/12/
    • http://somedomain.com/photos/12
    • http://www.somedomain.com/photos/12/
    • http://www.somedomain.com/photos/12
    • http://www.somedomain.com/photos/twelve/
    • http://www.somedomain.com/photos/twelve

    If all of these point to the same photo, then please, for the love of God, permanently redirect them all to just one of those four URLs. I don’t care which one (I would pick the first one) — but pick one and make sure people are always redirected there, no matter which of the four they actually type.

    Canonical URIs are good. Multiple URIs for the same resource are bad. Period.

  6. February 12, 2008 by Erik Töyrä

    Roger

    But when this sort of thing has happened to clients, it usually turns out that whoever is hosting the site has simply forgotten about it.

    This is my experience also. With the basic experience of webservers and DNS I have I would say it is either lazyness, ignorance or just plain lack of competence of the hosting company that causes this. Usually it is not hard at all to setup domains with both www. and without.

    This is how I do it in the httpd.conf in Apache. There might be better ways to do it but this forwards all requests to example.com to www.example.com with a 301 permanent redirect RewriteRule.

    <VirtualHost *:80>
        ServerName www.example.com
        ServerAlias example.com
        RewriteEngine On
        RewriteRule ^/(.*) http://www.example.com/$1 [L,R=301]
    </VirtualHost>
    

    The RewriteRule is not neccesary but it is recommended to do so to be SEO friendly.

  7. The most annoying of these for me is Internic: http://internic.net/

    And there is a good pst at Daring Fireball on how to make sure to have an unique URI, no matter wether the site is accessed with or without www.

  8. I think you are exaggerating this a bit, although your are right that it is very nice when sites works without www.

    More important is the domain name itself, which is why i must rant a little about your own.

    Mostly I come to this site via RSS-feed, but sometimes i’m forced to type the name 456bereastreet.com. Very often it becomes 456bereuastreet or something even worse, luckily “456 roger” works in google ;-)

  9. At least PPK has finally fixed quirksmode.org ;-)

  10. Erik, I use to to the opposite:

    1. <VirtualHost *:80>
    2. ServerName example.com
    3. ServerAlias www.example.com
    4. </VirtualHost>

    Don’t know if it’s a problem though. Is it?

    For almost a year, I served my site without the “www.” sub domain. I wasn’t aware of the problem, since all other sites which referenced mine also skipped the “www.” sub domain, and google only indexed my pages without it as well. My only reason to add the ServerAlias was me knowing about it.

    I added it a few week ago, thinking the same as you Roger: “COL, why can’t they let me skip the ‘www.’?!”, and it got me thinking: maybe there are a few “www-yes”-people which tries to reach my website and won’t find it.

    Google still indexes the top domain only, fyi. But at least the direct navigation is more accessible now.

  11. Roger, it’s actually so easy, it’s absolutely outrageous to forget about proper redirection from version to the other.

    Two lines in .htaccess file.

  12. Hear hear!

  13. I completely agree. I recently discovered that my own website doesn’t work without the ‘www’ part and it annoys the hell out of me. I’m considering moving to another hosting provider, and then I will take care of that annoying problem as well.

    By the way, great comment by Jeff Croft, that’s really something to keep an eye out for.

  14. February 12, 2008 by Erik Töyrä

    @Anders Ytterström

    No, your configuration should work just as good. But i recommend you to consider to choose one of example.com and www.example.com as the main domain to which you forward the other. Jeff Croft explains it well in his post above.

    Add the following to your configuration to forward all visitors from example.com to www.example.com.

    RewriteEngine On
    RewriteRule ^/(.*) http://www.example.com/$1 [L,R=301]
    
  15. Yes, more than agree with you. I usually skip www, and don’t think it’s normal to get an error message.

    Funny though, a no-www URL of my work site takes you into a login/pass page if accessed from inside the organization.

  16. February 12, 2008 by Dan Butcher

    My hosting service provides the following options:

    Both http://www.domain.com/ and http://domain.com/ work.

    Add “www.” if somebody goes to http://domain.com/

    Remove “www.” if somebody goes to http://www.domain.com/

    I’ve always used the first—allow both to work, but now I’m wondering if I should choose one of the other options so that my site appears with only one URL regardless of how a visitor gets there. Any thoughts?

  17. Amen. I am no DNS or hosting expert either. But I had myself in situations where I had to set them up and it took me an extra 5 seconds to make sure both www and no-www work (Apache/BIND/whatever) - which means it’s just pure negligence not to do it. And it’s a total rip-off to charge extra money for that (which I know does happen).

  18. On my sites either will get you there. If the www is used you’ll come to the site, but the www will be stripped from it. Done via .htaccess.

  19. What if, as is the case in many large business entities, the bareword domain (no www) is pointed to another machine that is not a web server, but some other type of server, possibly a VPN endpoint? Do you want the traffic to be re-routed to the web server then? I would think not. Stop being lazy and type the extra 4 characters. The internet is so much more than just the web.

  20. Or even worse, when you enter comhem.se and then click to login to your acccount and a certificate warning appears and tell you that the certificate isn’t valid for comhem.se but for www.comhem.se

    This is truely annoying and looks to me like a true rookie mistake. Which is a bit scary since comhem.se is a pretty big company.

  21. @JGM> What about one more DNS entry for vpn.domain.com and more generally service-acronym.domain.com ? It costs nothing and you won’t lose clients searching for your website at (nothing)domain.com Those who use a VPN know what a subdomain is.

    This advice about subdomain www is one of the hundred best practices described at http://en.opquast.com/ , it’s worth a look if you’ve quality in mind.

  22. February 12, 2008 by Jeffrey Skinner

    For the longest time, the worst offender was adobe.com ….I found that inexcusable.

  23. JGM:

    What if […] the bareword domain (no www) is pointed to another machine that is not a web server, but some other type of server, possibly a VPN endpoint? Do you want the traffic to be re-routed to the web server then?

    If it’s being requested via http, sure, why not. I recognize that it would entail some additional configuration, but why place the burden on the users when it can be addressed with a little work on the part of the site owner?

    If I use ftp://mydomain.com via port 21, I expect to get my FTP server. If I use http://mydomain.com via port 80 or 443, I expect to get my HTTP server. Yes, “the internet is so much more than just the web,” but internet requests include more than just domain names.

  24. February 12, 2008 by Tom von Schwerdtner

    @Anders Ytterström:

    That can still cause trouble. I find it best to do:

    <Virtualhost *:80>
      Servername www.example.com
      Redirect Permanent / http://example.com/
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName example.com
      # Normal site config here...
    
    </VirtualHost>
    
  25. February 12, 2008 by Dan Kubb

    I usually use the following rewrite rule to redirect the non-www version of the domain to the www version:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^(?<!www\.)([a-z]+\.com)$ [NC]
    RewriteRule /(.*) http://www.%1/$1 [R=permanent,L]
    
  26. The question that arises then, is… with the advent of OpenID, no www. makes most sense. After all, www.456bereastreet.com is a different identity from 456bereastreet.com, and it’s impossible for a script or program to tell for certain if they are the same or not. Of course, a scripter could build in the assumption that any www. is equal to the same address without it, but then sometimes it isn’t. So no www., would be the best option in a world of search engines and OpenID. Which reminds me, have you ever noticed how many duplicate entries are in Google simply because one page is often listed as www. and also with it? Either way, for me it’s just important that a site/coder is consistent. If one uses www., then use it everywhere and don’t forget some won’t type it in and should never need to type it in. If one codes without using www. in their links, etc, they shouldn’t forget that some people will type in the www.

  27. Last year the same discussion was in germany, many pro and cons are named.

    For myself I type by habit “www” in front of the domain name to go to Google or something else. So I add “Rewrite” rules in the .htaccess file of my domain. Now all my visitors are redirected to “www.domain.com” whatever url they type in the address bar of their browsers.

  28. A couple of my clients are on Microsoft IIS server, to which I have no control panel access and .htaccess files don’t work. What then? In the past I’ve just been stuck, but maybe someone here knows how to convince the server admin that this is a good idea.

  29. I believe one of the reasons that used to be valid for not using the domain name as a host is that poorly-implemented SMTP clients would screw up delivery to that domain.

    When an SMTP client or server goes to deliver mail to example.com, it should check for an MX record first. In the absence of an MX record for example.com, it should try to resolve the host example.com, and deliver mail to its IP address if one exists. This actually applies to every host, not just hosts that happen to be domain names. I.e. if your mail server has a message to john_doe@host.example.com, it should query host.example.com for an MX record before attempting to resolve it.

    Anyway — and this is not something I’ve ever run into myself — the story goes that some software would (erroneously) fail to check for the presence of an MX record if the domain name resolved to an IP address. The SMTP client would then dutifully send all of the mail @example.com to the host example.com, which would be the web server if you had assigned it so. To fix this, I presume you would either not define a top-level A record, or assign it the IP address of your primary mail server.

    An unrelated problem may be that the built-in Windows DNS manager attempts to tell you that the top-level host record is invalid, and shows you a scary pop-up. If your Windows admin doesn’t know what he’s doing, he’ll probably be discouraged from ever adding the record in the first place.

    A recent use case is interesting, though. As some of you know, many anti-spam techniques rely on the non-compliance of the spam-spewing SMTP clients.

    One newer method of spam prevention is to have no MX records in place for your domain, and instead create an A record for the domain name that points to your mail server. The idea is that spam clients will check for an MX record, and give up upon failure. Non-spam clients that comply with the SMTP RFCs would fall back to the domain/host’s A record appropriately. You can even add round-robin A records for redundancy.

    I should add as a word of caution that I have not personally tried to implement this as of yet. I’m just playing devil’s advocate by offering some possible justifications.

  30. When I changed hosting companies my site automatically defaults to no www, so now I find myself skipping the www almost every time I type a URL for any site.

  31. I remember when I first starting with the corporate website at work I got our admins to make it so that the site would work without the www. We use IIS Kevin. An argument you could use is that it makes for shorter URLs in advertising, and perhaps direct them to this post?

    I also find it annoying when a web address does not work without the www. Some prominent websites do this (of course I can’t think of any now)

  32. “I’m no DNS or web hosting expert, so there may well be technical reasons that I am unaware of that make it hard or impossible to…”

    No, it’s quite simple. It’s also something that has a tendency to be overlooked for some reason. Thanks for bringing it up again :)

  33. As JGM pointed out above, it’s not always so simple. Even small corporations can have the case where the bare domain and the www subdomain refer to separate servers. It could be a load balancer or a firewall device or a VPN server. To get this to work, that server or device will need to explicitly listen to and redirect all HTTP port 80 requests, and system administrators might not want to do that for some reason.

    Our site (http://www.skiviez.com/, a men’s underwear store, which some people find NSFW) forcibly redirects users to the www subdomain. We use MonoRail on IIS, and we’ve written a filter that’s wrapped around every page request that checks for this and redirects if necessary. There are other ways to do it (just create another Web site for the bare domain in the IIS Configuration Manager and tell that content should come from “Redirection from a URL” and specify the www version), but an application-based approach lets us do neat things like track these things.

    Not that we actually do that. But now I’m intrigued to add some logging in our next update and gather statistics on it.

  34. Here’s another one to add to your list of results:

    • A totally different website is configured

    Can’t remember which website it was unfortunately.

  35. February 13, 2008 by Rajveer

    I believe this problem mainly causes if a domain is not setup with both URLs (with and without WWW). So it mainly depends on web hosting service provider.

    Even if someone is unaware of all these technical terms he can always ask to support guys for resolving the same.

  36. swefair.se www.swefair.se

    quite emberrasing imo…

  37. a good info. but most of the solution here is in apache. can someone help me on how to do it in IIS? thank you.

  38. Ilyas,

    How to redirect a domain with IIS - http://www.xoc.net/works/tips/domain.asp

  39. It’s even more annoying if the site already is on a subdomain, especially a short www-like one. A client of mine had a site on something like:

    vg.domain.com

    That didn’t lead to anything though, so you had to type

    www.vg.domain.com

    After one bad request, I resorted to google that redirected me to the right place. For the first 10 times I visited…

  40. excluding the www will supposedly resolve the domain faster.

  41. @Roger: I completely agree.

    @Nicholas: If it is indeed a load balancer, then you’ll probably want all of your traffic to go there, right? That way, you can figure out which machine is most appropriate to handle the request.

  42. @Michael Jackson:

    How should the URL affect loadbalancing?

  43. I think the best solution is to have only one domain working (eg: www.domain.com) and redirect to it in some cases (when you miss the www for instance). That way there is only one real website and no sort of website duplication.

    A little (useful) trick I got from Defensive Design for the Web: sometimes you may miss or type too many w’s, so it’s nice for the website to redirect you correctly. I thus use a rule like:

    (w+\.|)domain\.com(.*) => www.domain.com$2
    

    I can then type domain.com, ww.domain.com, wwww.domain.com or even more w’s, it doesn’t matter: I’ll always be redirected to www.domain.com.

  44. More and more I tend not to put in the www and usually it works. It is after all a slightly ridiculous convention.

  45. As web site designers, websites with this problem are fairly common and very annoying to us. We had a real nightmare setting up a custom domain for a client blog at blogger.com last year. We could forward the client URL to the blog, but it only worked with the www. in front. Finally we found the step by step directions below to work around it and get it working both ways to go to the proper web site. http://www.bloggerforum.com/modules/newbb/viewtopic.php?topicid=18113&forum=2&postid=75481

    Dan Butcher-For your web site, you might want to be careful about switching your primary URL to remove the www. I understood that Google views them as two different domains and that it’s best to have all the links to your site be one way or the other. Anybody know if that’s still true?

  46. February 19, 2008 by delinear

    It’s not just being lazy and not wanting to type the “www.” - as you pointed out, many companies use just their bare domain in advertising, and this includes write-ups online. Additionally, many company names and domains are the same thing. In these cases if I come across the name in an article and it’s not linked, I’ll just copy-paste the name and if the site doesn’t display, I’ll often assume it’s dead when in fact it might just require the www… this probably happens a lot and it must be costing businesses for such a simple fix.

  47. Lazy sysadmins can’t type a single line to solve this problem.

  48. As a non-tech, for me the www seems without any real purpose. Could I have http://www.robin.com and http://robin.com set up to be different sites? I would have to be a couple of sandwiches short of a picnic to CHOOSE to have different sites names amost identically! Practically I find I can also omit the http:// or https:// over 99% of the time as well!! But from the grass roots level, saying “double-you-double-you-double-you-dot” sounds like you’re either dribbling or repeating some sort of arcane spell. We can do without it and it looks like a pair of hornrimmed spectacles. Ditch the woo woo goo goo!! :)

  49. I prefer dropping the www. and even the http:// when going to sites.

    When I write about a site, I usually drop the www automatically.

    Quite often people even drop the .com for example in top50s of visited websites, etc.

    On the other hand, I’m fond of del.icio.us, lifestrea.ms, grou.ps and some others seem to launch a new phenonemon of integrating the extension into the name itself.

  50. hey, lots of good info here, particularly such info such as this: (w+.|)domain.com(.*) => www.domain.com$2

    Im on Networksolutions and I would really like to use this redirect. Having a tough time, been trying alot of rewrites that I have googled up. Any help would be appreciated.

    None of my rewrites have worked to get the www.domain.com to change to domain.com.

  51. thanks for this i will try it!

  52. Over the past week, I have noticed a few errors on my website that worked perfectly fine before. I never put “www” before a url but when I added “www” to my url, all the errors were gone. It’s really frustrating. Is there any simple way of making every page automatically redirect with the www before it? I don’t understand how to use some of those thinks listed above so could you include some kind of instructions on how to make it work? would be very helpful. thanks.

  53. This was so helpful to read. I’m going through the exact same situation right now. The company I bought the domain from say it’s impossible for them to register my site without the www… even though their site works just fine without it.

    I pass on my address 99% of the time by word of mouth or via my business card… so I’m reliant on the person typing the www. If they exclude it they get a server not found message and, I fear, move on to something else with an assumption that I can’t even keep a website running.

  54. March 20, 2008 by Ray Woodard

    Ok. Im running iis on an 03 server and need to get the domain www.lcibuilders.com to work as http://lcibuilders.com I read the messages above but am looking for a specific method of correcting this either via iis or dns on the server. the resolution to create a domain lcibuilders.com and then www.lcibuilders.com doesnt seem to work

    thnak you

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.