Using a very short URL in MediaWiki hosted on Dreamhost

I was setting up a small wiki site to track my music collection and track details and was trying to set up short urls like “http://wiki.myhost.org/Main_Page” instead of “http://wiki.myhost.org/index.php?title=Main_Page”

From all the reading up I did on various forums and wiki’s I was preparing for a long night ahead of me to get this working. However it turned out be a anti-climax with the URL’s working after only a couple of trials. Here’s how I did it.

Installed mediawiki using the oneClick install on wiki.myhost.org and then changed

this ->

$wgArticlePath = "$wgScript?title=$1";

->to this

$wgArticlePath = "/$1";

and then created a file .htaccess at ~/wiki.myhost.org/.htaccess and added the following lines in it

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

I’m not sure at this point how completely it works, as I have just started experimenting with it. It sure rendered the Main_page and all the pages linked to the Main_page correctly, including Search. So am happy for now. Will report back if I run into issues. If I don’t, assume I’m doing just fine.

Thanks for the help guys.

4 comments

  1. It doesn’t work to me ….
    I did put your .htaccess (there wasn’t one before) at my www localhost root: …\wos\www
    then I did put the same also on wikimedia dir
    after adding these lines to \includes\setup.php:

    $wgArticlePath = “/$1”;

    // Set various default paths sensibly…
    if( $wgScript === false ) $wgScript = “$wgScriptPath/index.php”;
    if( $wgRedirectScript === false ) $wgRedirectScript = “$wgScriptPath/redirect.php”;

    if( $wgArticlePath === false ) {
    if( $wgUsePathInfo ) {
    $wgArticlePath = “$wgScript/$1”;
    } else {
    $wgArticlePath = “$wgScript?title=$1”;
    }
    }

    What i did wrong?…..

  2. it works, but you have to change/set in LocalSettings.php
    this:
    $wgScriptPath = “”;
    $wgArticlePath = “/$1”;

  3. Sorry about that, have been busy with some personal stuff and not paying much attention to the site. Will update the adsense ads placement and numbers as needed, not making much from them in any case 🙂 thanks for taking the time to let me know.

Leave a Reply