Mediawiki Fix Internal Server Host Names / Redirection In shared Hosting or Proxy Setup

If you have a MediaWiki installation in a shared hosting environment or behind a proxy, you may encounter issues with internal server host names and redirection. Here are some steps you can take to resolve these issues:

  1. Modify the $wgServer setting in your LocalSettings.php file:
$wgServer = "http://your.server.name";

This should be set to the fully qualified domain name (FQDN) or IP address of the server that MediaWiki is running on.

  1. Modify the $wgUsePathInfo setting in your LocalSettings.php file:
$wgUsePathInfo = true;

This will enable the use of clean URLs in MediaWiki, which can help resolve issues with internal host names and redirection.

  1. Modify your server’s Apache or Nginx configuration to handle internal host name and redirection issues:

For Apache, you can use the RewriteRule directive to handle internal host name and redirection issues:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.your\.server\.name$ [NC]
RewriteRule ^(.*)$ http://www.your.server.name/$1 [L,R=301]

For Nginx, you can use the server_name and return directives:

server {
listen 80;
server_name your.server.name;
return 301 $scheme://www.your.server.name$request_uri;
}

These configurations will redirect all requests to the correct host name, which should resolve any internal host name and redirection issues.

Note: these configurations are just examples, and you may need to modify them based on your specific server setup and requirements.

Leave a Comment