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

htaccess - Multisite Subdirectory Site Dashboard redirect loop

programmeradmin2浏览0评论

I recently activated multisite and received my code to add to wp-config.php.

WordPress wanted to force me to use subdomains.

I wanted to use subdirectories, so I used:

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 );

I then used the .htaccess code from this answer:

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).*) /$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ /$2 [L]
RewriteRule . index.php [L]

However, I still receive a redirect loop when trying to load www.example/au/wp-admin/:

This page isn’t working 
www.example redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

I have cleared my cookies and the issue remains.

Help appreciated.

EDIT

I created a blank local MU subdirectory site and copied its .htaccess:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
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]

but the error remains.

I recently activated multisite and received my code to add to wp-config.php.

WordPress wanted to force me to use subdomains.

I wanted to use subdirectories, so I used:

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 );

I then used the .htaccess code from this answer:

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).*) /$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ /$2 [L]
RewriteRule . index.php [L]

However, I still receive a redirect loop when trying to load www.example.com/au/wp-admin/:

This page isn’t working 
www.example.com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS

I have cleared my cookies and the issue remains.

Help appreciated.

EDIT

I created a blank local MU subdirectory site and copied its .htaccess:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
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]

but the error remains.

Share Improve this question edited Mar 10, 2022 at 8:36 Steve asked Mar 10, 2022 at 8:29 SteveSteve 1,75719 gold badges66 silver badges115 bronze badges 3
  • 1 What is the nature of the redirect loop? ie. What is it redirecting to/from/to/...? – MrWhite Commented Mar 10, 2022 at 9:00
  • @MrWhite, I am unsure. If I load /au/wp-admin/ it redirects to /au/wp-admin/. – Steve Commented Mar 10, 2022 at 12:17
  • 1 "If I load /au/wp-admin/ it redirects to" - is that trailing slash part of the request? Check the network traffic in the browser devtools. Knowing what the redirect loop actually consists of is the first step to figuring out what is going on. You should also check the HTTP response headers to determine the status code and what is triggering the redirect(s). The .htaccess code you posted should not be triggering a redirect loop. There is only a single redirect to append the trailing slash. ie. /au/wp-admin would be redirected to /au/wp-admin/. – MrWhite Commented Mar 10, 2022 at 12:39
Add a comment  | 

1 Answer 1

Reset to default 1

I spoke to the web host, WP Engine, who advised us that an extra license is required to turn a WP site into MU, which we don't currently have.

They confirmed the error was caused by our lack of a MU license.

发布评论

评论列表(0)

  1. 暂无评论