I have a Wordpress multisite configuration like this:
www.domain/
-> Primary site (not used)www.domain/de-de/
-> German sitewww.domain/en-us/
-> English site
However, for reasons unrelated to Wordpress, I need that the network sites have this layout:
www.domain/de-de/blog/
-> German sitewww.domain/en-us/blog/
-> English site
Unfortunately, you cannot define a site as de-de/blog
in your WP network because the forward slash is not an allowed character for a site name.
Therefore, I tried defining a reverse proxy like this on Apache:
ProxyPreserveHost On
ProxyPass "/de-de/blog/" "http://127.0.0.1/de-de/"
ProxyPassReverse "/de-de/blog/" "http://127.0.0.1/de-de/"
ProxyPass "/en-us/blog/" "http://127.0.0.1/en-us/"
ProxyPassReverse "/en-us/blog/" "http://127.0.0.1/en-us/"
This seems to do the trick for site routing, but in the returned page, the internal URLs in the HTML page are www.domain/de-de/
, not www.domain/de-de/blog/
How could I have WP in multisite mode use URL layout from upstream (i.e. www.domain/de-de/blog/
) in the rendered HTML pages?
I have a Wordpress multisite configuration like this:
www.domain/
-> Primary site (not used)www.domain/de-de/
-> German sitewww.domain/en-us/
-> English site
However, for reasons unrelated to Wordpress, I need that the network sites have this layout:
www.domain/de-de/blog/
-> German sitewww.domain/en-us/blog/
-> English site
Unfortunately, you cannot define a site as de-de/blog
in your WP network because the forward slash is not an allowed character for a site name.
Therefore, I tried defining a reverse proxy like this on Apache:
ProxyPreserveHost On
ProxyPass "/de-de/blog/" "http://127.0.0.1/de-de/"
ProxyPassReverse "/de-de/blog/" "http://127.0.0.1/de-de/"
ProxyPass "/en-us/blog/" "http://127.0.0.1/en-us/"
ProxyPassReverse "/en-us/blog/" "http://127.0.0.1/en-us/"
This seems to do the trick for site routing, but in the returned page, the internal URLs in the HTML page are www.domain/de-de/
, not www.domain/de-de/blog/
How could I have WP in multisite mode use URL layout from upstream (i.e. www.domain/de-de/blog/
) in the rendered HTML pages?
1 Answer
Reset to default 0I fixed it changing the urls of the sites to include the /blog/
suffix. You cannot create the site with a slash but you can change the site URL once it is created.
Then changing the RewriteRules in .htaccess to:
RewriteRule ^([_0-9a-zA-Z-]+/blog/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteRule ^([_0-9a-zA-Z-]+/blog/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/blog/)?(.*\.php)$ $2 [L]
Finally, adding some code to wp-config.php
to properly define the PATH_CURRENT_SITE
and BLOG_ID_CURRENT_SITE
variables:
define('PATH_CURRENT_SITE', $path_current_site);
define('BLOG_ID_CURRENT_SITE', $blog_id_current_site);