WordPress MU and www domains

  • english
  • spanish

WordPress MU warns you during the install process that it will NOT let you use a www. domain for your page like in www.domain.tld, following the trend by no-www.org. I think that this www MATTERS, I’m going to explain why and how to remove this limit from WPMU so that you can use a www. domain.

Why would I want to call my page www.domain.tld and not just domain.tld? On the first place, because it’s my web and my domain and I’m free to choose the name I want. With all due respect for the otherwise great program they’ve made, the WPMU developers don’t have the right to force their particular beliefs or preferences on me.

On the second place, the main argument on the no-www.org web against using the “www.” seems to be that they think it’s redundant, so the protocol part on the URI (”http://”) already tells you that it’s a web. It also tells the browser that it should use a given port instead of another, so you should be able to have http://domain.tld, ftp://domain.tld and so forth without any problems. But saying this they don’t realize there are problems ahead: what if those two services don’t run on the same machine? If both machines are on your local network and you control the routers, you can NAT each port to a different computer. Big deal. But, what if you want to move one of those services to an external provider?

Picture yourself a small company that puts online its public web and a private ftp, and decides to call both just “domain.tld”. On their DNS, domain.tld points to their DSL’s IP address, and using NAT they point ports 21 and 80 to different servers. No problem. But time goes on, the company grows, their web attracts a lot more traffic and their DSL line can’t handle it any longer. They decide to move their web to an external hosting compay but want to keep the private ftp on their server. What now? DNS works at IP level, not IP:port level, so you can’t point domain.tld:80 to an IP address and domail.tld:21 to another. This company would have to rename one of their services (www.domain.tld or ftp.domain.tld), which depending on the service itself, the use they make of it, and the type and number of users can be quite a seriuos issue.

I’ve suffered this very problem myself: on the DNS of the company I work for, we’ve always setup the mail.domain.tld, smtp, pop, pop3, imap and webmail domain names for our mail server, despite all of them pointed to the same IP address. But with time and out of lazyness, almost everybody ended up using just the generic “mail.domain.tld” for every protocol. The thing is that because of some network and server restructuring we had to undertake, we needed to take services appart, having smtp on one IP and the other protocols on another. So, what happens to the generic “mail.domain.tld” name and all the people that used it for both smpt, pop and webmail? After several months of warning about the change and actually making it, we still get some calls about the mail server “not working” because of this…

All in all: it’s a good practice calling independent services by their names, and even if the protocol can identify one service from another under the same name, this policy of “one easy to remember name for everything and we’ll do NAT if we need to” can lead to deep trouble.

And of course, all of this only makes sense in WPMU if you plan to organize your blogs in folders (www.domain.tld/myblog)  and not in subdomains (myblog.domain.tld).

Back to WordPress, in order to remove the anti-www filter you only need to comment lines 8 and 9 on the wpmu-settings.php file (see below), check and maybe fix the domain on the “wp_site” and “wp_blogs” tables, and on the admin pannel go through all the blogs fixing the domain in every entry you find it. Before you do this, be sure to check that your server responds to both the domain with and without “www.”, or else you may end up with an unaccessible page after one of these steps. When you’re done with all the modifications, you can point the base domain back where it was and stick with the “www.” version.

$domain = addslashes( $_SERVER[‘HTTP_HOST’] );
//if( substr( $domain, 0, 4 ) == ‘www.’ )
//      $domain = substr( $domain, 4 );
if( strpos( $domain, ‘:’ ) ) {
if( substr( $domain, -3 ) == ‘:80′ ) {
Enviar a:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • BarraPunto
  • Meneame
  • Slashdot
  • Technorati
  • YahooMyWeb

Artículos relacionados (o no):

  • Pues no hay. :-(

3 Responses to “WordPress MU and www domains”


  1. 1 Salvador

    Enhorabuena por el artículo, de verdad.

    Llegué aquí buscando información sobre el wordpress MU, pero me ha gustado leer tu análisis de porque mantener las http://www.

    Saludos!

    Salva

  2. 2 bisente

    Vaya, muchas gracias por el comentario. Me alegro de que te haya gustado el artículo. :)
    Yo es que ya he sufrido en mis carnes el “un dominio para todo y luego NAT de puertos”. Una y no más, cada servicio con su nombre, que para eso está el DNS. :D

  3. 3 Abdussamad

    Amazingly this tip still seems to work even after all these months. I’d like to add that if you want to force the www version you can just replace the lines 9-10 in wpmu-settings.php with these lines

    if( substr( $domain, 0, 4 ) != ‘www.’ )
    $domain = “www.”.$domain;

Leave a Reply




Creative Commons Attribution-NonCommercial 2.5 Spain
Creative Commons Attribution-NonCommercial 2.5 Spain