0

I have a Wordpress multisite configuration like this:

  • www.domain.com/ -> Primary site (not used)
  • www.domain.com/de-de/ -> German site
  • www.domain.com/en-us/ -> English site

However, for reasons unrelated to Wordpress, I need that the network sites have this layout:

  • www.domain.com/de-de/blog/ -> German site
  • www.domain.com/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.com/de-de/, not www.domain.com/de-de/blog/

How could I have WP in multisite mode use URL layout from upstream (i.e. www.domain.com/de-de/blog/) in the rendered HTML pages?

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.