最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

multisite - Hosting 2 WordPress websites in public_html & public_htmlsubdirectory at the same time

programmeradmin1浏览0评论

Previously, we had a subdomain multisite in /public_html/:

  • www.example (primary site)
  • site1.example
  • site2.example

plus another subdirectory multisite in /site3.example/

  • site3.example (primary site)
  • site3.example/subsite4

It got decided that we'd use subdirectories across the board. So now we have

  • www.example (primary site)
  • www.example/site1
  • www.example/site2

All of these work fine.

However

  • www.example/site3 &
  • www.example/site3/subsite4

display a 500 internal server error - too many redirects.

I've updated www.example/site3's wp-config.php to ensure:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.example/site3');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Its .htaccess is:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site3/
RewriteRule ^index\.php$ - [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 . /site3/index.php [L]
</IfModule>

I've updated the tables:

  • wp_2_options
  • wp_blogs
  • wp_options

with the new URLs: www.example/site3

The .htaccess in /public_html/ is:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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>

The /public_html/wp-config.php contains:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.example');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Is the site in /public_html causing the site in /public_html/site3 problems?

How would I resolve this, please?

Help appreciated.

Previously, we had a subdomain multisite in /public_html/:

  • www.example.com (primary site)
  • site1.example.com
  • site2.example.com

plus another subdirectory multisite in /site3.example.com/

  • site3.example.com (primary site)
  • site3.example.com/subsite4

It got decided that we'd use subdirectories across the board. So now we have

  • www.example.com (primary site)
  • www.example.com/site1
  • www.example.com/site2

All of these work fine.

However

  • www.example.com/site3 &
  • www.example.com/site3/subsite4

display a 500 internal server error - too many redirects.

I've updated www.example.com/site3's wp-config.php to ensure:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.example.com/site3');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Its .htaccess is:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site3/
RewriteRule ^index\.php$ - [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 . /site3/index.php [L]
</IfModule>

I've updated the tables:

  • wp_2_options
  • wp_blogs
  • wp_options

with the new URLs: www.example.com/site3

The .htaccess in /public_html/ is:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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>

The /public_html/wp-config.php contains:

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Is the site in /public_html causing the site in /public_html/site3 problems?

How would I resolve this, please?

Help appreciated.

Share Improve this question edited Feb 4, 2022 at 13:00 Steve asked Feb 4, 2022 at 12:37 SteveSteve 1,75719 gold badges66 silver badges115 bronze badges 3
  • I'm confused by your setup. Is site3 a multisite install or not? If these sites were on a multisite then there wouldn't be a site3 folder with a wp-config.php file. That's just a separate install entirely. – Jacob Peattie Commented Feb 4, 2022 at 12:46
  • @JacobPeattie, yes, site3 is a subdirectory multisite. I've moved site3.example.com to www.example.com/site3 – Steve Commented Feb 4, 2022 at 12:51
  • "site3 is a subdirectory multisite" - so you have a subdirectory multisite within a subdirectory multisite? – MrWhite Commented Feb 4, 2022 at 20:50
Add a comment  | 

1 Answer 1

Reset to default 3

The problem was caused by:

define('DOMAIN_CURRENT_SITE', 'www.example.com/site3');
define('PATH_CURRENT_SITE', '/');

Changing this to:

define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PATH_CURRENT_SITE', '/site3/');

with a similar change in the wp_blogs table solved the problem.

发布评论

评论列表(0)

  1. 暂无评论