Is it possible to install WordPress within WordPress installation?

I have a website that is powered by WordPress, e.g. example.com. I would like to install a separate WordPress installation with a separate database, themes, etc in a subdirectory on my website though, for example on example.com/blog.

Will this cause problems with displaying both installations properly? For example if I try to go to example.com/blog or example.com/blog/post will this cause installation A to throw up a 401 error since it didn’t find a page within the original example.com WP installation?

Related posts

3 comments

  1. Yes, you can do this. There won’t be a 404 error because of the default rewrite rules that WordPress has (if you use ‘nice URLs’, if don’t, there is no default .htaccess at all).

    Because of the exceptions (see below) if there is a ‘real’ directory or file in the directory of your WordPress installation, WP won’t treat it as a URL for a page or post.
    So this way you can install one or more new WP instances into a ‘parent’ WP directory.

    You can check the rewrite rules in the .htaccess file.

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    

    These are the exceptions:

    If string is not a valid file:

    !-f
    

    If string is not a valid directory:

    !-d
    
  2. Yes it is possible to have a WordPress installation within another WordPress installation. I had a working prototype configured as follows. The directories looked like this:

    /filesystem/wpA_base
    /filesystem/wpA_base/wpB_base

    I had a multisite sub-directory installation at wpA and another multisite sub-directory installation at wpB. I also installed Domain Mapping plugin on wpA so that I had these domains:
    http://www.example.com (main wpA site)

    http://www.example1.com or example1.example.com (wpA sub-site)

    http://www.example2.com or example2.example.com (wpA sub-site)

    http://www.example.com/wbB_base (main wpB site)

    http://www.example.com/wbB_base/subsite1 (wpB sub-site)

    http://www.example.com/wbB_base/subsite2 (wpB sub-site)

    I didnt have any problems with wpA interferring with wpB urls. Even if I did, I could always apply .htaccess rules in wpA_base/.htaccess to not respond to wpB urls.

  3. I was trying to do this very thing and could not get .htaccess rules to behave for anything but the subdirectory I wanted to exclude. Requests to ‘/careers/’ would load my sub-site, but ‘/careers/photo-gallery’ would be handled by the containing sited.

    Context: I inherited a WordPress multisite and was contracted to build a careers subsite that described company culture and interfaced with a 3rd party recruiting solution. I built a test site and migrated that to a subdirectory on the main site once it was approved.

    Ultimately, I modified the index.php of the containing site so it looks like this:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, 
     * but loads
     * wp-blog-header.php which does and tells WordPress to load the 
     * theme.
     *
     * @package WordPress
     */
     if (strpos($_SERVER['REQUEST_URI'], "/careers") === 0)
     {
         require (dirname(__FILE__) . '/careers/index.php');
     }
     else
     {
         /**
          * Tells WordPress to load the WordPress theme and output it.
          *
          * @var bool
          */
         define('WP_USE_THEMES', true);
    
         /** Loads the WordPress Environment and Template */
         require( dirname( __FILE__ ) . '/wp-blog-header.php' );
     }
    

    Yes, I feel like I’m doing it wrong, but that feels better than the hours I lost trying to figure out why rewrite rules weren’t behaving as I expected.

Comments are closed.