• I want to create two multisites that use subdomains but use the same domain. I want them separate instances for security and other reasons.

    I installed a multisite with subdomains to my site stocklighting.com. I have set a wildcard subdomain and everything works great for that multisite instance. I installed a second multisite with subdomains in the folder stocklighitng.com/private.

    I then created two subdomains for each multisite.
    primary:
    sub1.stocklighitng.com, sub2.stocklighting.com,
    private:
    sub3.stocklighting.com, sub3.stocklighting.com

    The mulitisite in private lets me create a subdomain site just fine the only issue is it appends the root folder name to the end of the url which in this case is /private.
    sub3.stocklighting.com/private and sub4.stocklighting.com/private

    what I want to do is hide the /private so it doesn’t show in the url I’ve played around with the htaccess on both sites and can’t get it to work.

    This is the htaccess for the Mulitisite install in the root directory
    # BEGIN WordPress
    RewriteEngine On
    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).*) $1 [L]
    RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    # END WordPress

    This is the htaccess for the multisite installed in the /private directory

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ – [L]
    RewriteRule ^(wp-(content|admin|includes).*) private/$1 [L]
    RewriteRule ^(.*\.php)$ private/$1 [L]
    RewriteRule . index.php [L]

    # END WordPress

    Does anyone who know server and apache rewrites better than I do have any advice on how I can get this structure to work? Like I said it works, but if I remove the subfolder extension from any site on my second multisite it resolves to the first one and it thinks I’m trying to register a new site.

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

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    The mulitisite in private lets me create a subdomain site just fine the only issue is it appends the root folder name to the end of the url which in this case is /private.
    sub3.stocklighting.com/private and sub4.stocklighting.com/private

    Yes, because it’s in a subfolder. That’s what’s supposed to happen here.

    What’s the purpose of the private folder? You just want a separate network for some subdomains?

    Thread Starter ammonlee

    (@ammonlee)

    That is correct. We have over 100 subdomains we want to manage with multisite. I know Multisite can support thousands, but we were hopping to split them up into four multisite instances so that they would be isolated in case of a hack of any kind. We get a lot of traffic to our sites and a lot of attempts to hack user login and such. If someone was able to get access to the server or wordpress login we wanted to limit what they had access to. Also in the future we may port them off to another server and domain. In that case it would be easier to split. We would just have the folder and the database to transfer over. Then just update the DB for the new domain and subdomains.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Well. You would want to make the start of all this a subdomain, so private.example.com

    And then off of that you’ll make subfolder (yes, I know, hold on) sites like private.example.com/sub1

    And THOSE you will treat like mapped domains to map sub1.example.com to private.example.com/sub1

    Does that make sense? You basically have to trick WP.

    Thread Starter ammonlee

    (@ammonlee)

    Okay I think I follow.

    1. I make private.example.com and install multisite. I use subfolders instead of subdomains?
    2. create each of my websites in multisite in a subfolder. ie. private.example.com/sub1
    3. For the mapping I create the subdomain in my cpanel? then map it to the respective site in multisite. ie. sub1.example.com -> private.example.com/sub1
    Is there a best way to map it?

    Am I missing anything?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Actually you’d map sub1.example.com to private.example.com…

    In cPanel I believe it works out to mapping it to /public_html/private

    And then you want a domain mapping plugin to tell WP what’s up 🙂

    You can do it without a plugin as well if you want: http://halfelf.org/2014/mapping-domains-without-plugin/

    Thread Starter ammonlee

    (@ammonlee)

    That makes sense. I feel like i’m so close but just missing something. Here are some screenshots of my setup. I am guessing it has to do with the path. I tried changing it like the link you gave said but it just defaults to the primary subdomain.

    Thread Starter ammonlee

    (@ammonlee)

    Actually I think I figured it out. When you change the domain you have to set the path to /. It seems to be working. Only downside to this is that when you go to sites it shows all of them as just / instead of the name of the site.

    Thread Starter ammonlee

    (@ammonlee)

    Okay I have successfully gotten the subdomains working. The only issue I am running into now is when I want to go to the dashboard of one of my sites from the network manager page it isn’t keeping my session so I get the wordpress login screen for each site. I know with a regular multisite setup the super admin can bounce around any sites that they have access to. Any ideas?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    You may need to fiddle with these:

    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', '');

    Basically it’s not unexpected, the browser properly sees them as separate sites and thus for your protection, makes you log in again.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Two multisites, One domain’ is closed to new replies.