Page MenuHomePhabricator

Help with setting lighttpd redirects for wmf.org test site
Closed, ResolvedPublic

Description

NOTE: This isn't a bug but a request for help

The test website for the new design of https://wikimediafoundation.org/ is currently deployed on Toolforge at https://tools.wmflabs.org/wptestblog2/.

It is an instance of Wordpress with multisite enabled for sub-directories (as opposed to sub-domains). Each site in the multisite is for a language (using https://multilingualpress.org/).

On my local instance, running Apache I have the following .htaccess file:

RewriteEngine On
RewriteBase /
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]

And this is what the wp_blogs and wp_site table looks like:


With @Samwilson's help I was able to get the English website and its dashboard to show up properly (it was earlier stuck in an infinite redirect loop). The current .lighttpd.conf is:

url.rewrite-once = (
  "^/wptestblog2/([_0-9a-zA-Z-]+/)?wp-admin$" => "/wptestblog2/$1wp-admin/",
  "^/wptestblog2/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" =>
"/wptestblog2/$2",
  "^/wptestblog2/([_0-9a-zA-Z-]+/)?(.*\.php)$" => "/wptestblog2/$2",
)
url.rewrite-if-not-file = (
  "^/wptestblog2(/.*)" => "/wptestblog2/index.php$0"
)

If one tries to go to https://tools.wmflabs.org/wptestblog2/es/?noredirect=es_ES they are redirected to a page whose name starts with "es", in this case https://tools.wmflabs.org/wptestblog2/profile/esraa-al-shafei/, instead of going to the language's site, like in
https://wikimediafoundation.org/es/.

I am not facing this problem with the above htaccess file with Apache locally. Also note that my local instance runs on localhost:8888, and not in a directory to begin with like in the case of https://tools.wmflabs.org/wptestblog2.

Event Timeline

Prtksxna created this task.Apr 15 2019, 1:08 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 15 2019, 1:08 PM
GTirloni removed a subscriber: GTirloni.Apr 15 2019, 3:06 PM
bd808 added a comment.Apr 18 2019, 4:34 AM

Can you add some logging in both your local install that is working as desired and the tool that is misbehaving to capture the full URL as seen by the index.php dispatcher script? Things are getting rewritten to the dispatcher or you would be getting a 404 response. Seeing the difference in the rewritten URLs should make it easier to figure out what needs to be adjusted in the lighttpd rewrite rules.

It may be that it's failing to match /wptestblog2/es/ to the es site, and is instead finding the first match on the default site, because it's comparing the incoming request path with the various configured paths of the different sites and not taking into account the trailing slash properly (so either they should all have a trailing slash, or not; I'm not sure which).

Note that there are also site paths configured in each of the wp_*_options tables. I don't know if those are compared as well.

Also, I just noticed in the dump we were talking about the other day that all the non-main sites have the private attribute set. Could that be interfering here?

bd808 added a comment.Jul 1 2019, 4:27 AM

@Prtksxna is this still an active issue?

No, it is resolved now. Sorry, I forgot to close it.

We ended up using the test VIP instance which managed all of this for us.

Prtksxna closed this task as Resolved.Jul 1 2019, 10:58 AM
Prtksxna claimed this task.