MediaWiki TLD pages don't work

I migrated my MediaWiki install to HestiaCP install and my TLD pages, such as /w/.com don’t work, just says 404. Its some sort of rewrite issue, because I can access it fine if I do /index.php?title=.com so its weird. Any fixes? Here’s my site: https://iiwiki.com/w/.cf_(Thermodoliaverse) and here’s our .htaccess file:

RewriteEngine On

# Don't rewrite these — they are actual files used by MediaWiki
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/w/load\.php
RewriteCond %{REQUEST_URI} !^/w/rest\.php
RewriteCond %{REQUEST_URI} !^/w/resources/

# Rewrite /w/... to index.php
RewriteRule ^/?w(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]

# Redirects /wiki to /w
RewriteRule ^wiki(/.*)?$ /w$1 [R=301,L] 

# Rewrite root to index.php
RewriteRule ^/*$ %{DOCUMENT_ROOT}/index.php [L]

This is in our LocalSettings.php file:

$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/w/$1";

I’ve tried to fix this for a while, but I’m desperate now, please help

Try adding Options -MultiViews at the top of your .htaccess

That did not fix it unfortunately

Ok, I see the problem. The issue is caused by this location block in the Nginx conf:

        location ~ /\.(?!well-known\/|file) {
                deny all;
                return 404;
        }

That location denies access to all files starting with a dot (.), except for .well-known. In your case, you should create a new Nginx template and remove the existing location block. Once done, assign the new Nginx template to your site.

Warning: Keep in mind that removing this location block will make files starting with a dot (.) accessible. Make sure to check that you don’t have any sensitive files of this type.

In this example I will assume you are using the default template for nginx, your user is test and the domain is example.net.

cd /usr/local/hestia/data/templates/web/nginx
cp default.tpl mediawiki.tpl
cp default.stpl mediawiki.stpl

Now edit mediawiki.tpl and mediawiki.stpl and remove this block:

        location ~ /\.(?!well-known\/|file) {
                deny all;
                return 404;
        }

Once done in both files, assign the new template to your site:

v-change-web-domain-proxy-tpl test example.net mediawiki yes

That worked! Thank you so much for your help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.