Support » Networking WordPress » trying to shift document root on existing subdir multisite

  • So, I will start this off by admitting right up front that I may be going about this entirely the wrong way, and I’m happy for any and all guidance on different paths/strategies to make this work.

    The situation is this: I have a multisite (subdirectory) install of WP that lives in /var/www/wordpress. My document root is /var/www, and other, static content lives under the rest of this tree. So this means that my sites have urls like http://www.server.com/wordpress/testsite. This works totally fine, were it not for those pesky users. I have been asked to get rid of “wordpress” inside the url string.

    After banging my head against various apache redirects and doing some testing on a separate server, the best solution seemed to be to move DocumentRoot to /var/www/wordpress, and use redirects in apache to catch static content urls and bypass WP. On my test server, where I set it up this way from the get-go, this worked lovely.

    So now I’m trying this on my production server (well, on a clone of it, anyway) and the problem is that I have a lot of existing sites. I changed DocumentRoot in apache, changed the .htaccess in /var/www/wordpress to reference / instead of /wordpress/, updated wp-config.php, and updated all the tables in my wordpress db using the recommended Search and Replace tool to change http://www.server.com/wordpress/ to http://www.server.com/. I also updated wp_site and wp_blogs to be correct.

    Now what happens is if I go to http://www.server.com I get my main wordpress site. This works. I can log in to wp_admin, yay!

    So: http://www.server.com –> goes to wordpress primarysite
    http://www.server.com/wp-admin –> goes to wp-admin page for primary site

    But:
    http://www.server.com/primarysite –> gives a WP Page Not Found error.

    All my non-primary sites are also broken. When I try to “visit” them either from My Sites or directly by URL, I get the same Page Not Found error. However, when I go to http://www.server.com/secondarysite/wp-admin, I can actually log in to the wp-admin page. If I create a post from there, though, it publishes it to my primary site.

    My guess is that there’s something else in the db that needs to get changed that I haven’t found, and I’m at a loss for next things to look for or try.

    Help?

    Thanks so much 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    In your database go to the wp_blogs table

    Make sure the PATH is set to / and not /wordpress/

    Thread Starter oxtoe

    (@oxtoe)

    Unfortunately, I updated those when I did my original database search & replace. No go. 🙁

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    What’s in your .htaccess?

    Thread Starter oxtoe

    (@oxtoe)

    in /var/www/wordpress:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    
    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    </IfModule>
    
    # END WordPress
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Bleah. This is normally why we stress NOT trying to give WP it’s own directory after you’ve Multisite’d it.

    Okay…

    Go into wp_2_options and look for the option_name HOME and SITEURL

    SiteURL should be example.com/wordpress (i.e. where WP is installed)

    Thread Starter oxtoe

    (@oxtoe)

    Yeah, caught that too on my previous attempts. Still doesn’t work. And it wasn’t my idea to move wordpress; it was the idea of the person who signs my paychecks. So you do what you gotta.

    I’ve mostly given up on this and am trying a different workaround, but thanks for trying.(-:

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    I’d cheat, reinstall WP where you want it, and see how the DB looks. Then copy the per-site tables over.

    Thread Starter oxtoe

    (@oxtoe)

    So yes, putting this here for the next hapless person who comes along.

    The method I’ve got that seems to be working (so far) is I set up apache2 and multisite wordpress on a fresh server with /var/www/wordpress as the DocumentRoot. I have a directory inside there called static_content, under which all my non-WP content lives, and I use aliases in my apache conf to get to it.

    Exporting/importing the sites has mostly worked, in part because the new server believes it has the same name as the old server (a local entry in /etc/hosts that falsely convinces the new server of its identity, so that I can get work done on it w/o taking down my production server until I’m ready to change over DNS) so that the only URL strings changing are http://www.myserver.com/wordpress –> http://www.myserver.com (and I’ve run into “www.myserver.com\/wordpress” in a few places, not sure what artifact generates these escaped entries, but it’s a separate search/replace.) I use the Interconnect/IT tool which seems recommended everywhere.

    Where this breaks is media, because of course the tool for exporting your entire site *doesn’t* export the media — it expects to connect to the previous server and copy it over on its own. This doesn’t work at all if either a) your original server is down, or b) your new server can’t reach the old server because you’ve faked it out using /etc/hosts to think it IS the old server. So, one thing that would have made my life (and the lives of a lot of other people, judging by googling) easier is if the export tool had at least an *option* to include the media directly in the export bundle. As a result I’m using a third-party plug-in to do the media export/import, and then have to use the Interconnect/IT tool to again change the db values of “uploads/sites/x/yyyy/mm” to the new site and media location value. Tedious but not too onerous, although I’d expect that if your multisite install had a lot of sites that had been around for a long time and accumulated a lot more media than mine have, the irritation of this would escalate quickly.

    Hope that makes sense. I’ll know next week when I pull the plug on my old server if I missed anything.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘trying to shift document root on existing subdir multisite’ is closed to new replies.