I have an instance of WordPress set up at https://wordpressinstance.example.

I have an instance of MediaWiki set up at https://mediawiki.wordpressinstance.example.

The MediaWiki instance is multilingual, and each language wiki is accessible from the fourth level:

  • English : https://en.mediawiki.wordpressinstance.example
  • Italian : https://it.mediawiki.wordpressinstance.example
  • etc.

I have an Apache Virtual Host for the WordPress instance, with document root set to /var/www/vhosts/wordpressinstance/httpdocs.

I have an Apache Virtual Host for the MediaWiki instance, with document root set to /var/www/vhosts/wordpressinstance/mediawiki.

In order for the fourth level domains to point at the same document root as the third level domain in the MediaWiki instance, I have a wildcard ServerAlias directive:

ServerAlias *.mediawiki.wordpressinstance.example

And these are the rewrite rules in the Virtual host configuration for the MediaWiki:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.mediawiki\.wordpressinstance\.example [NC]
RewriteRule ^(.*)$ https://mediawiki.wordpressinstance.example$1 [L,R=301]

RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
# Redirect / to Main Page
RewriteCond %{HTTP_HOST} ^(.*)\.mediawiki\.wordpressinstance\.example$
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

This setup has been working nicely for at least 6 months now, however recently the MediaWiki instance started acting strangely, it won't load CSS or JS resources apparently. When accessing https://en.mediawiki.wordpressinstance.example (which correctly redirecs to https://en.mediawiki.wordpressinstance.example/wiki/Main_Page, I'm seeing these errors:

GET https://en.mediawiki.wordpressinstance.io/w/load.php?debug=true&lang=en&modules=ext.uls.pt&only=styles&skin=vector net::ERR_ABORTED 404
Main_Page:138 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=ext.wikimediaBadges&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:139 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=jquery.makeCollapsible.styles&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:137 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=ext.visualEditor.desktopArticleTarget.noscript&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:140 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=mediawiki.toc.styles&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:142 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=wikibase.client.init&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:141 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=skins.vector.styles.legacy&only=styles&skin=vector` net::ERR_ABORTED 404
Main_Page:143 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=startup&only=scripts&raw=1&skin=vector` net::ERR_ABORTED 404
Main_Page:145 GET `https://en.mediawiki.wordpressinstance.example/w/load.php?debug=true&lang=en&modules=site.styles&only=styles&skin=vector` net::ERR_ABORTED 404

If I try accessing the MediaWiki load script directly (https://en.mediawiki.wordpressinstance.example/w/load.php), I simply get redirected to the base domain (https://wordpressinstance.example) with a "404 page not found" error.

I have done some tests to see what is happening here. I created a phpinfo.php file under /var/www/vhosts/wordpressinstance/httpdocs, under /var/www/vhosts/wordpressinstance/mediawiki, and under /var/www/vhosts/wordpressinstance/mediawiki/w.

  1. Accessing https://mediawiki.wordpressinstance.example/phpinfo.php correctly shows PHP info, and correctly shows /var/www/vhosts/wordpressinstance/mediawiki as document root
  2. Accessing https://en.mediawiki.wordpressinstance.example/phpinfo.php also shows PHP info, however incorrectly shows /var/www/vhosts/wordpressinstance/httpdocs as document root

This brings me to believe that the Apache ServerAlias directive is not working correctly. But since it has been working correctly for the past 6 months, and only started to go wonky just recently, I wonder if it maybe has something to do with recent changes to Apache?

The only changes on my server that could possibly affect something like this, were:

  1. an update from Apache 2.4.48 to Apache 2.4.49 a little over a week ago that screwed up my PHP-FPM instances, which are available over unix sockets
  2. to fix that, I removed Ondrej Sury's Apache PPA, removed Apache, and reinstalled the system Apache (I'm on Ubuntu 20.04, which installed Apache 2.4.41)
  3. This got the websites back up again, for about a week, then they all went offline again
  4. In the meantime I had opened issues on the Plesk community forum, on Ondrej Sury's github repo for his Apache PPA, and on the Apache mailing list. Apache acknowledged the error, and has put fixes in place, which Ondrej Sury pulled into his Apache 2.4.49 build
  5. Following Ondrej Sury's latest updates, I added his PPA back and updated Apache, which is now back to v2.4.49 and is correctly communicating with PHP7.4-FPM over unix sockets
  6. All websites are back up again, only MediaWiki is acting strangely, not loading CSS or JS and not allowing logins

And going back to the phpinfo.php tests:

  • Accessing https://mediawiki.wordpressinstance.example/w/phpinfo.php correctly shows PHP info and the document root is correctly set to /var/www/vhosts/wordpressinstance/mediawiki
  • Accessing https://en.mediawiki.wordpressinstance.example/w/phpinfo.php redirects to the base domain https://wordpressinstance.example with a 404 page not found error
  • What are the ServerName and ServerAlias directives in each of these vHosts? (Port 80 and Port 443.) In what order are they being loaded? Are ServerName, ServerAlias or DocumentRoot defined outside of these vHost containers in the main server config?
    – MrWhite
    Commented Sep 30, 2021 at 19:09
  • "https://en.mediawiki.wordpressinstance.example/w/phpinfo.php redirects to the base domain https://wordpressinstance.example" - Redirects to the root? Or to the same URL-path (ie. /w/phpinfo.php) but at the other host? Find the possible "redirect" directives that might be doing this and change the HTTP status (eg. to 307 or 303) and see if this is reflected in the browser's response.
    – MrWhite
    Commented Sep 30, 2021 at 19:39

1 Answer 1


It looks like perhaps the <VirtualHost> containers are defined/loaded in the wrong order and requests for XX.mediawiki.wordpressinstance.example are seemingly matching the wrong vHost.

The first vHost that matches will "win".

Either changing the order of the vHosts and/or being more specific with the ServerName and ServerAlias directives in the wordpressinstance.example vHost might solve an issue like this. Each vHost container should contain a ServerName and an optional ServerAlias directive. If ServerName is omitted then it is calculated, which may cause issues.

Note that vHost .conf files are often included in the main server config using an Include (or IncludeOptional) directive with the help of a wilcard to perhaps include all *.conf files in a particular directory. These files are included in alphabetical order, which can affect the behaviour.

This behaviour has not changed between Apache 2.4.48 and 2.4.49 AFAIK.

  • I was able to finally fix this issue by adding a server_name directive for each of the language wikis to the Additional nginx directives in the MediaWiki instance's virtual host panel in Plesk. This gave priority to the MediaWiki instance subdomain over the WordPress domain for the language wiki fourth level domains. Commented Oct 3, 2021 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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