WordPress.org

Ready to get started?Download WordPress

Forums

Domain mapping(?) child blog -> subdirectory to subdirectory not working (8 posts)

  1. design_dolphin
    Member
    Posted 3 years ago #

    Intro
    I have a backend which runs over SSL on a shared server.

    When creating a network I added the mysecuredomain.com to the settings, and set-up the multisite. I used the sub-directory option (tried subdomains as well, but would prefer the sub-directory option) This worked fine.

    I then installed WordPress MU Domain Mapping plugin, and pointed this to the yourwebsite.com domain. So now when I go to yourwebsite.com it shows the website, and the backend runs fine. Everything works fine.

    The problem

    However, when I create a child blog, I can't seem to figure out how to point the child blog to the yourwebsite.com/child-blog. It keeps giving a 404 error no matter what I try.

    I've read oodles of topics to get this far, but can't seem to solve it.

    Anybody have a clue?

    Thanks

  2. So.... you changed the domain of the main blog itself?

    Also, you can't map domains with a folder name. (not a wordpress limitation, but a domaining limitation. you can't even do this on blogger, for example)

    If you want one install with different domains with blogs under those domains, you need a multi *network* plugin, not the domain mapping one.

    http://wordpress.org/extend/plugins/wp-multi-network/

  3. design_dolphin
    Member
    Posted 3 years ago #

    @Andrea_r:

    Thank you for replying.

    So.... you changed the domain of the main blog itself?

    No. My apologies if this may seem unclear in the first post.

    In a clean install in the settings menu, I set the:
    site url: mysecuredomain.com
    home url: mysecuredomain.com

    Then created the network, per the instructions in the Create a Network Codex page.

    I then installed the WordPress MU Domain Mapping plugin, and network activated the plugin. Then in 'Domain Mapping' in the 'Super Admin' menu I set the IP address to the IP address listed in the DNS record for the yourwebsite.com domain. Then in 'Domains' in the 'Super Admin' menu I set under 'New Domain' Siteid to 1 (the ID of the main blog) and the 'Domain' to yourwebsite.com, selected 'Primary', and clicked save. Now that part works fine.

    The problem starts with adding a new child-blog. When I add yourwebsite.com/child-blog as a new domain then instead of going from:
    https:/mysecuredomain.com/child-blog to http://yourwebsite.com/child-blog it goes to https://yourwebsite.com/child-blog. And at https there is nothing. But I can't get the URL to point at the http. Maybe I need to do some .htaccess rewriting?

    If you want one install with different domains with blogs under those domains, you need a multi *network* plugin, not the domain mapping one.

    I'll look into the plugin you recommended. From what I read WordPress MU Domain Mapping plugin should be able to handle subdirectories, hence me getting stuck on this.

  4. design_dolphin
    Member
    Posted 3 years ago #

    I've done everything per instruction, the little that there is, for the WP Multi Network plugin. At the assigned url (tried different ones) nothing shows, just redirects to http://mysecuredomain.com (without the https) and the yourwebsite.com gives a 404.

    When I assign a child-blog to a new network, I can't find any way to access the backend. Have no clue where to log in to those sites. And if I do have to log-in seperately, I might just as well just run different WP installs. And unless I'm mistaken my child-blogs (paths) are now totally borked. Luckily I made backups.

    Technically it should be possible. Just no clue how, right now. The part I don't understand is why if I map the domain of the main blog in the WordPress MU Domain Mapping plugin the sub-directories don't just automatically follow. That is something that would make it a lot easier.

  5. From what I read WordPress MU Domain Mapping plugin should be able to handle subdirectories,

    It will handle sites in the format of yourdomain.com/blogname and turn them into aseconddomain.com. that's what people mean. When the plugin first came out it only worked on subdomain blogs.

    The part I don't understand is why if I map the domain of the main blog in the WordPress MU Domain Mapping plugin the sub-directories don't just automatically follow. That is something that would make it a lot easier.

    It;s the way DNS itself works.

    You can;t map a blog to aseconddomain.com and tell it to pick up the /blogname/ part and stuff it in the URL.

    like I said above, you can't even do this with Blog. And Google runs that.

    So, if you want
    yourmaindomain.com
    yourmaindomain.com/site1
    yourmaindomain.com/site

    and
    aseconddomain.com
    aseconddomain.com/site3
    aseconddomain.com/site4

    you absolutely have to use a multi network plugin. I have used John's, as I have my own version, but to create a new network, I do not create a site for it first. I let the plugin do that part.

    I still need to do the DNS work so my install "catches" the second domain.

    This is hardcore server stuff. Not lightweight point and click.

  6. design_dolphin
    Member
    Posted 3 years ago #

    The thing I don't understand though is that when I have a normal WP 3.0 install I can set in the settings:

    site url: mysecuredomain.com
    home url: yourwebsite.com

    and that works.

    It is only when I want to install multi-site that both 'site url' and 'home url' have to be the same, and the problems begin.

    I'd rather see the ability to keep the 'site url' and 'home url' different. And have the multisite backend run in 'site url' and the front end in 'home url'.

    From what I read all paths are virtual, and therefore this should be possible. I am just wondering if I should just concentrate on writing a plugin, doing .htaccess rules, or both.

  7. It is only when I want to install multi-site that both 'site url' and 'home url' have to be the same, and the problems begin.

    I'd rather see the ability to keep the 'site url' and 'home url' different. And have the multisite backend run in 'site url' and the front end in 'home url'.

    Because this difference screws up the sub-blogs. The addresses are built using site_url as the base. No way around it.

    realy, we dealt with this a lot in WPMU. It's not possible. And it was discussed quite a bit during the merge.

    htaccess will not fix it.

  8. design_dolphin
    Member
    Posted 3 years ago #

    Thank you @Andrea_r for taking the time to explain things. I really appreciate it.

    As soon as my site is back up, and I have some spare time (and the motivation) I'll take a look at it again.

    This is what I've thought out so far. I'm not saying it would work, but it may help someone else looking to do this as well:

    Note important!: This is brainstorming. Do not implement any of this on a live website, without a backup, and you know absolutely what you're doing.

    1. In multisite wp_options table add column 'home_url' (according to the same specs as the 'siteurl' column?), and add here yourdomain.com.
    2. In multisite child-blogs wp_*_options tables change the value in the column 'home' to yourdomain.com/child_blog.
    3. One option could be to insert code somewhere in WordPress to do custom rewriting en routing, through a plugin.
    4. Another option could be do it (partly) in the theme:
      a. Selecting path to blog pseudocode:

      $path_parts = $_SERVER['REQUEST_URI'];
      		$pattern = "/[\/\/|\.]/";
      		$a = preg_split($pattern, $path_parts, 0, PREG_SPLIT_NO_EMPTY);
      $path_part = $a[1];
      
      if ($path_part == child_blog ) { 
      
      switch to database for child_blog
      
      }

      See also: $_SERVER documentation for getting the proper variables, to tell the difference between domains.

      b. Pseudocode in the header.php of the theme before anything else:

      <?php
      
      // automatically replace in the theme all references to mysecuredomain.com to yourdomain.com 
      
      function replaceurl($bff){
      $pzcr=0;
      $pzed=strlen($bff)-1;
      $rst="";
      while($pzcr<$pzed){
      $t_poz_start=stripos($bff,"<textarea",$pzcr);
      if($t_poz_start===false){
      $bffstp=substr($bff,$pzcr);
      $temp=stripBuffer($bffstp);
      $rst.=$temp;
      $pzcr=$pzed;
      }
      else{$bffstp=substr($bff,$pzcr,$t_poz_start-$pzcr);
      $temp=stripBuffer($bffstp);
      $rst.=$temp;
      $t_poz_end=stripos($bff,"</textarea>",$t_poz_start);
      $temp=substr($bff,$t_poz_start,$t_poz_end-$t_poz_start);
      $rst.=$temp;
      $pzcr=$t_poz_end;
      }
      }
      return $rst;
      }
      
      function stripBuffer($bff){
      $bff=str_replace('https://mysecuredomain.com','http://yourdomain.com', $bff);
      return $bff;
      }
      ob_start("replaceurl");
        ?>
      
      // Doctype 
      
      <head>
      
      // Normal head stuff. 
      
      </head> <?php  flush(); ?>
      
      // start html
      
      <html>

      Caching the theme would cut out any overhead. For the search page there could be a custom template made.

    As well as any other code that might be needed.

    O.k. that is how far I've gotten so far. Theoretically it should work fine.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags