Difference between revisions of "Setup friendly URLs for MediaWiki on Apache2"
Jump to navigation
Jump to search
m (Discorddigital moved page Creating Setup friendly URLs for MediaWiki on Apache2 to Setup friendly URLs for MediaWiki on Apache2) |
m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<h2>Prologue</h2> | <h2>Prologue</h2> | ||
<p>When setting up MediaWiki you'll quickly realize that pages use /index.php.< | <p>When setting up MediaWiki you'll quickly realize that pages use /index.php.<br> | ||
This can be annoying especially for search engines.<br> | |||
To fix this we can do following changes:</p> | To fix this we can do following changes:</p> | ||
<h2>Modifying LocalSettings.php</h2> | <h2>Modifying LocalSettings.php</h2> | ||
<p>We append following code to it:</p> | <p>We append following code to it:</p> | ||
< | <syntaxhighlight lang="php"> | ||
$wgArticlePath = "/$1"; | |||
$wgUsePathInfo = true; | $wgUsePathInfo = true; | ||
$wgGenerateThumbnailOnParse = false;</ | $wgGenerateThumbnailOnParse = false; | ||
</syntaxhighlight> | |||
<h2>Creating .htaccess</h2> | <h2>Creating .htaccess</h2> | ||
<p>We need to create ".htaccess" on our web root of MediaWiki.</p> | <p>We need to create ".htaccess" on our web root of MediaWiki.</p> | ||
<p>Make sure the apache server has mod_rewrite enabled.</p> | <p>Make sure the apache server has mod_rewrite enabled.</p> | ||
<p>.htaccess:</p> | <p>.htaccess:</p> | ||
< | <syntaxhighlight lang="apacheconf"> | ||
RewriteEngine On | RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^(.*)$ index.php?title=$1 [NC,L,QSA] | RewriteRule ^(.*)$ index.php?title=$1 [NC,L,QSA] | ||
</ | </syntaxhighlight> | ||
<h2>Conclusion</h2> | <h2>Conclusion</h2> | ||
<p>After we reload our page, we should land on /Main_Page which makes URLs a lot friendlier.</p> | <p>After we reload our page, we should land on /Main_Page which makes URLs a lot friendlier.</p> | ||
[[Category:MediaWiki]] | [[Category:MediaWiki]] |
Latest revision as of 22:18, 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.