I work as a sysadmin at a large academic department. We have an apache httpd, with a WP subdirectory multisite installation, fronted by an apache reverse proxy. In this setup we want to allow our users to serve WP content under the main domain name (external.com
, say) with their own name attached (user1
):
The vhost config looks like
# ...
RequestHeader set X-Forwarded-Proto "https"
ProxyPass / http://internal.com/
ProxyPassReverse / http://internal.com/
ProxyPreserveHost On
# ...
This allows us to assign users their own wp sites, as user1
, with siteurl and host both set to https://external.com/wpsites/site1
, and they can edit and publish.
And we want to add sites for whole research projects, with their own domain names, that should be addressed as a bare domain name: https://project1.com
. I’ve set the vhost config like this:
# ...
RequestHeader set X-Forwarded-Proto "https"
ProxyPass / http://internal.com/wpsites/project1
ProxyPassReverse / http://internal.com/wpsites/project1
ProxyPreserveHost On
# ...
With siteurl and host both set to https://project1.com
, this gives a 404 error on the root, with an ‘Oops!’ for the home page, and goes into 301 loops on permalinks.
With siteurl and host both set to https://external.com/wpsites/project1
, there is a redirect to the main site root when trying https://project1/
, but the permalinks work …
The rewrite rules look like
RewriteEngine On
RewriteBase /wpsites/
# if req NOT lastly from reverse proxy, redirect thru it
# -- 'cause direct access doesn't work
RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111$
RewriteRule ^(.*)$ https://external.com/wpsites/$1 [R=301,L]
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]
EDIT: additional configuration that may shed some light:
- the WP site is in a subdirectory of the httpd docroot (it’s implicitly mentioned above)
- the domain is set to
project1
and the path to/
in thewp_blogs
table
Is this possible, at all? How, in that case? Changes to the .htaccess file? To the vhost config? To the siteurl and host options? Move the site to the docroot? Change the domain/path values in the wp_blogs
table?