Creating Short URLs - MediaWiki - Version 1.10.0
June 2, 2007 – 5:41 pm | by gaulardcom
|
|
Yeah, this took me a little while to figure out. I started last night and noticed that the clock was ticking rather quickly. I had to move away from the computer…MOVE AWAY FROM THE COMPUTER.
One of the most important things you can do for any website is to create pretty URLs for your pages, or what MediaWiki calls, “Short URLs.” The technique basically turns…
http://www.dotwiki.us/wiki/index.php?title=Main_Page
into something more like…
http://www.dotwiki.us/wiki/Main_Page
You get the idea of how short urls get rid of all the ugly ?, = and &. URLs like that are hard to remember and search engines just don’t like them. Google recently mentioned that they treat both ugly and pretty URLs the same, but I haven’t found any evidence of that.
So, how to get pretty URLs (or short URLs) in your Wiki? I will tell you that I tried each and every one of MediaWiki’s suggestions and none of them worked for me. It’s strange, because it almost seems like there is no continuity between the developers of this software. There are so many suggestions for so many things. I suppose that might be because of the various server configurations of so many users.
I searched in many web forums out there and came up with a solution that worked for me. I found it here and this is it…
My wiki is installed in /public_html/wiki and the clean url for my main page now comes up as http://www.mysite.com/wiki/Main_Page.
I added the following to .htaccess file located in /public_html.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^wiki/(.+)$ /wiki/index.php?title=$1 [L,QSA]
I also changed (or added) the following in LocalSettings.php located in /public_html/wiki.
##### ADDED FOR SHORT URLS #####
$wgScript = "$wgScriptPath/index.php";
$wgRedirectScript = "$wgScriptPath/redirect.php";
$wgArticlePath = "$wgScriptPath/$1";
##### ADDED FOR SHORT URLS #####
Thanks to trailville for this one. Just remember, when using this method, be sure to only have one .htaccess file, and keep it located in the root directory.

6 Responses to “Creating Short URLs - MediaWiki - Version 1.10.0”
By Paul on Jun 3, 2007 | Reply
Jeez, take the weekend off and get left in the dust
By gaulardcom on Jun 3, 2007 | Reply
HAHA…that’s why I don’t take weekends off.
By Paul on Jun 5, 2007 | Reply
OK, my wiki is up and running, although it does not have the pretty URLs yet. I can’t figure that one out.
http://www.sun-volt.com/wiki
I will work a little more on the front page
By gaulardcom on Jun 6, 2007 | Reply
Looks good…don’t worry, it only took me 2 days to get the logo and short URLs right.
By Mariotendo on Jun 20, 2007 | Reply
Wow, thank you for this! This worked unlike the ones on MediaWiki o.O