在 CI 主站点中使用重写(在 CI 的重写脚本之后),
RewriteEngine On
RewriteCond %{HTTP_HOST} (.*)\.domain\.tld$
RewriteCond %{HTTP_HOST} domain\.tld$
RewriteCond %{HTTP_HOST} ^domain\.tld[NC]
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.tld$
RewriteCond %{HTTP_HOST} !^(lp|subdom1|sub2dom2)\.domain\.tld$ [NC]
然后永久重定向到,
RewriteRule ^(.*) https://www.domain.tld/%1/$1 [L,R=302]
然后在WP中,
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)$ $1 [L]
RewriteRule . index.php [L]
现场示例与 CI、https://www.gsunitedtechnologies.com(子域:https://blog.gsunitedtechnologies.com)以及在 https://beatthedrumfor.com 上具有多站点 wp 网络的同一主机(子域:https :// in.beatthedrumfor.com)