• Almost everything is nice – the only thing that was not satisfactory is the fact that plugin developers assumed that I don’t like the www prefix, and that I want it to be removed. This is not true – I want my blog to work the same no matter what visitor enters in the browser address bar: domain.com or http://www.domain.com).

    Solution is to change two files:

    Solution is to change two files:

    In line 55 of file domain_mapping.php, change:
    $wpdb->escape( preg_replace( "/^www\./", "", $_POST[ 'domain' ] ) );
    to
    $wpdb->escape( $_POST[ 'domain' ] );

    And in line 112 of the same file, change
    echo "http://www.<input type='text' name='domain' value='' />/";
    to
    echo "http://<input type='text' name='domain' value='' />/";

    In line 10 of file sunrise.php, change:
    $wpdb->escape( preg_replace( "/^www\./", "", $_SERVER[ 'HTTP_HOST' ] ) );
    change to
    $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );

    Anyway, when you do that, you just add two domains (www and without-www) for the same blog.

    http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Unfortunately that’s not good enough for inclusion. To handle both www and none, you should only have to add one domain record. Adding both is redundant.

    I found a workaround.
    Only thing you have to do in addition to all changes you have specified…

    in <b>sunrise.php</b>, add following code…

    if( "www." != substr( $_SERVER[ 'HTTP_HOST' ] , 0 , 4) ){
    	header("Location: " . "http://www." .  $_SERVER[ 'HTTP_HOST' ] .  $_SERVER[ 'REQUEST_URI'] , TRUE, 301);
    	exit;
    }

    before line…

    $dm_domain = $wpdb->escape( $_SERVER[ 'HTTP_HOST' ] );

    I agree with Donncha on restriction of one domain record per domain. Having your site accessible on both WWW and non-WWW URL’s is really bad SEO.
    I really wish I could make this work a step further where this plugin will allow and respect WWW prefix choice made by blog owner.

    As of now, if you want no WWW, use Donncha’s plugin out of the box. Otherwise use cvladan’s and above code.

    Now only problem left is, you can not have different prefix choice for different domains. Its either all or none.

    @Donncha
    Thanks a ton for this great plugin. I would have never moved all our blogs to wpmu, had not I found this plugin.
    As you are the genius behind wordpress MU, please consider having this plugin as “blog option” in next wordpress core. It won’t take much space but can really increase reliability. 🙂

    !important

    Please use following code with one modification…

    if( ( “www.” != substr( $_SERVER[ ‘HTTP_HOST’ ] , 0 , 4) ) && ( !strpos( $_SERVER[ ‘HTTP_HOST’ ] , “wpmu.com”) ) ){
    header(“Location: ” . “http://www.&#8221; . $_SERVER[ ‘HTTP_HOST’ ] . $_SERVER[ ‘REQUEST_URI’] , TRUE, 301);
    exit;
    }

    Code I posted yesterday breaks main wpmu site as well as other subdomains.
    DO NOT FORGET to replace “wpmu.com” in above codes with your root domain name where you have installed WPMU.

    lgh529

    (@lgh529)

    Why don’t you just edit your .htaccess file? Seems a lot simpler than messing around with a script redirect.

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{http_host} ^\.domain\.org [NC]
    RewriteRule ^(.*)$ http://www.domain.org/$1 [R=301,NC]

    @lgh529
    Your code above will work under normal circumstances but not here.

    First domain.org is not fixed. I am planning to have more than 100 domains mapped so writing individual rules for each of them is insane task!

    Next if you put code like above for even one domain, it will be stripped off by domain mapping plugin’s sunrise.php.
    I am not sure but if sunrise.php go for external redirection after stripping WWW prefix, .htaccess code will create infinite loop!

    cvladan I have a little problem with your codes. When I add only one domain with www. he works perfect, but when I add domain without www. he is like primary and domain with www. not work.

    Please help!

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘I want WWW domain prefix’ is closed to new replies.