マルチサイト htaccess

Subdomain

SubDomain Example

WordPress 3.5+

# 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).*) $1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
# END WordPress

https://wordpress.org/support/article/multisite-network-administration/#htaccess-and-mod-rewrite

WordPress 3.5 and up

SubDomain Example

# BEGIN WordPress Multisite
# Using subdomain network type: https://wordpress.org/support/article/htaccess/#multisite

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
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).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

# END WordPress Multisite

https://wordpress.org/support/article/htaccess/#wordpress-3-5-and-up

The usual rule redirects .php requests to an appropriate subfolder when used as RewriteRule ^(.*\.php)$ wp/$1 [L] like we see in the example in WP docs. But without the “wp/” it’ll just rewrite to the same place, causing an infinite loop situation, thus the 500 status.

Go to Network admin, then the Network Setup settings. Does the .htaccess code there exactly match what you have? If it does, you could try commenting the line out by placing a # at the start of the line. I’m not sure what impact it’ll have on your network, but I don’t see what purpose it serves if not to redirect to a different sub-folder.

https://wordpress.org/support/topic/multisite-htaccess/#post-15051764

Subdirectory

RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

サブフォルダで上記ルールに該当する存在しないファイルへのアクセスがあるとリダイレクトループが発生する。

/wp-content/uploads/sites/1/fbrfg/site.webmanifest が存在しない状態で
https://yournetwork.com/site1/wp-content/uploads/sites/1/fbrfg/site.webmanifest にアクセス

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to
increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

以下の方法で対処可

Ok. I messed around with this. I think I have something.

Instead of changing the rewrite rule, Change:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

To:

RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

This works by checking internal Apache variable %{ENV:REDIRECT_STATUS}. This variable is empty at the start of rewrite module but is set to 200 when first successful internal rewrite happens. This above condition says bail out of further rewrites after first successful rewrite and stops looping.

WordPress Multisite: How to fix error "too many redirects" · GitHub