Difference between revisions of "Setup friendly URLs for MediaWiki on Apache2"

From DiscordDigital Wiki
Jump to navigation Jump to search
(Created page with "<h2>Prologue</h2> <p>When setting up MediaWiki you'll quickly realize that pages use /index.php.</p> <p>This can be annoying especially for search engines.<br> To fix this we...")
 
(No difference)

Revision as of 20:27, 27 February 2021

Prologue

When setting up MediaWiki you'll quickly realize that pages use /index.php.

This can be annoying especially for search engines.
To fix this we can do following changes:

Modifying LocalSettings.php

We append following code to it:

$wgArticlePath = "/$1"; 
$wgUsePathInfo = true; 
$wgGenerateThumbnailOnParse = false;

Creating .htaccess

We need to create ".htaccess" on our web root of MediaWiki.

Make sure the apache server has mod_rewrite enabled.

.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?title=$1 [NC,L,QSA]

Conclusion

After we reload our page, we should land on /Main_Page which makes URLs a lot friendlier.