By Aron


2014-02-16 23:07:51 8 Comments

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?

3 comments

@J.D. Pace 2018-11-01 10:38:44

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.

@rocknrollcanneverdie 2014-02-17 00:24:39

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

@user42826 2014-02-16 23:54:54

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: www.example.com (main wpA site)

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

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

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

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

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.

Related Questions

Sponsored Content

2 Answered Questions

Multiple Multisite networks on the same domain?

4 Answered Questions

[SOLVED] How do I setup a WordPress site on a server before the domain is ready?

  • 2017-02-07 18:59:35
  • Chapman Atwell
  • 107 View
  • 3 Score
  • 4 Answer
  • Tags:   installation wp-cli

1 Answered Questions

1 Answered Questions

[SOLVED] Wordpress not handling subdirectory properly

1 Answered Questions

Use a single WP installation instead of three

1 Answered Questions

[SOLVED] Multi-site Installation in Wordpress | Security & Future Migrations

1 Answered Questions

Installing WordPress on a long temporary URL from host

1 Answered Questions

1 Answered Questions

3 Answered Questions

Sponsored Content