The MU forums have moved to WordPress.org

Redirect to www sub-domain automatically (5 posts)

  1. zylstra
    Member
    Posted 11 years ago #

    How can I redirect all requests for domain.tld to http://www.domain.tld?

    Thanks.

  2. ColdCN
    Member
    Posted 11 years ago #

    create a cname called "*" point to http://www.domain.tld.

  3. zylstra
    Member
    Posted 11 years ago #

    I'm using sub-domains for WPMU (not sub-directories), so if I do that no member blogs will work.

  4. drmike
    Member
    Posted 11 years ago #

    You can try reversing Matt's no-www plugin. I don't know if it would work though with the subdomains but you can try it.

    <?php
    /*
    Plugin Name: Gotta have WWW
    Plugin URI: http://tdjc.be
    Description: For those who want to be old school
    Author: Dr. Mike Wendell
    Version: 1.0
    Author URI: http://tdjc.be/
    */

    if ( strstr( $_SERVER['HTTP_HOST'], 'www.' ) )
    return;

    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http(colon)//www' . $_SERVER['REQUEST_URI']);
    exit();

    ?>

    Hmm, that would force all of your sites to have the www though which would mess some visitors up.

    Can't really think of any other method myself off teh top of my head.

  5. Xen
    Member
    Posted 11 years ago #

    Why do you want www? it's deprecated... the only people who actually use www are stubborn businesses and inexperienced users, I find the opposite to be more useful, a redirect from http://www.domain.ext to http://domain.ext ...

    Each to his own, I'm fairly sure that subdomain.www.domain.com won't work... you can use www. with subdirectories but not with subdomains to my knowledge... unless you can play with .htaccess to make it work... maybe...

About this Topic