• About Me
  • Best Of
  • Contact Me
  • Forum

Jay Gaulard

  • Home & Living
    • Automotive & Mechanical
    • Carpentry & Building
    • Entertainment
    • Firewood & Heating
    • Gardening
    • Home Improvement
    • Lawn Care & Landscaping
    • Pets & Animals
  • Fitness & Recreation
    • Brazilian Jiu-Jitsu (BJJ)
    • Bushcraft & Camping
    • Hiking & Walking
  • Nature & Outdoors
    • Trees & Shrubs
    • Weather & Seasons
  • Technology & Internet
  • Travel & Destinations
  • Writing & Blogging
    • Ramblings & Opinion
You are here: Home / Technology & Internet / Creating Short URLs – MediaWiki – Version 1.10.0

Creating Short URLs – MediaWiki – Version 1.10.0

June 2, 2007

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.example.com/wiki/index.php?title=Main_Page

into something more like…

http://www.example.com/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.

Related posts:

  1. Changing the Logo – MediaWiki – Version 1.10.0
  2. Creating Links – MediaWiki – Wiki Tutorial
  3. Wiki Installation – MediaWiki – Version 1.10.0
  4. Google Ranking Drop Because Of Duplicate Content
  5. How to Set Up a Custom 404 File Not Found Page

Filed Under: Technology & Internet

What’s Next? Email Updates!

If you enjoyed reading this post as much as I enjoyed writing it, why not sign up to receive my posts by email? It's free and you can unsubscribe at any time!

Comments

  1. Paul says

    January 8, 2017 at 5:22 pm

    Jeez, take the weekend off and get left in the dust

    Reply
  2. Jay G. says

    January 8, 2017 at 5:22 pm

    HAHA…that’s why I don’t take weekends off.

    Reply
  3. Paul says

    January 8, 2017 at 5:22 pm

    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.mysite.com/wiki

    I will work a little more on the front page

    Reply
  4. Jay G. says

    January 8, 2017 at 5:22 pm

    Looks good…don’t worry, it only took me 2 days to get the logo and short URLs right.

    Reply
  5. Mario Tendo says

    January 8, 2017 at 5:23 pm

    Wow, thank you for this! This worked unlike the ones on MediaWiki o.O

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CONNECT WITH ME

  • Email
  • Facebook
  • Google+
  • RSS
  • Twitter

RECEIVE MY POSTS BY EMAIL!

Interested in receiving my posts by email? This is your chance! Simply place your email address in the box below and I'll deliver each and every post I write directly to your inbox.

Copyright © 2021 · Jay Gaulard My Personal Blog Blog · About · Best Of · Contact · Privacy / Terms · Sitemap