!AfjWiki working notes

!AfjWiki working notes
Jump to: navigation, search

[edit] Short URLs

Try this, from MediaWiki .htaccess Solution

This is the result of two hours of wrestling with .htaccess and trying to get clean URLs out of MediaWiki, while also setting up exclusions for things like robots.txt, favicon.ico, and a stats package I have installed outside of the wiki. I was never able to get any RewriteCond statements working on Dreamhost, so I found out how to do everything with RewriteRule statements and the final result is pretty clean. Here's my full .htaccess for my testbed website http://www.highenergychemistry.com/

RewriteEngine on
RewriteRule ^statistics/$ statistics/index.php [L]
RewriteRule ^statistics/(.*)$ statistics/$1 [L]
RewriteRule ^favicon.ico$ favicon.ico [L]
RewriteRule ^robots.txt$ robots.txt [L]
RewriteRule ^$ wiki/index.php?title=Main_Page [L]
RewriteRule ^wiki/(. )$ wiki/$1 [L]
RewriteRule ^(.*)$ wiki/index.php?title=$1 [L,QSA]

The first four rules are exceptions, which allow the statistics/ directory, favicon.ico, and robots.txt to be served up normally. From what I can tell each directory needs two rules, one to redirect from the directory name to a file inside of it (the index file inside of it I presume) and one to pass-through everything inside the directory. The next line cleans up the homepage; when you go to http://www.highenergychemistry.com/ that URL stays in the address bar instead of redirecting you to /Main_Page or something to that effect. The last two rules are what make the clean URL rewriting work for MediaWiki, I copied these from somewhere else on the web but added the ,QSA which passes query strings through, so a URL like http://www.highenergychemistry.com/Main_Page?printable=yes will work as expected.
The LocalSettings.php editing was straightforward. $IP points to the full file path of the wiki directory under my webroot. The other (possibly) relevant settings:

$wgScriptPath = "/wiki";
$wgScript = "$wgScriptPath/index.php";
$wgRedirectScript = "$wgScriptPath/redirect.php";
$wgArticlePath = "/$1";

[edit] Favicon

How do I change the icon (favicon) in browser's address-line? (MediaWiki FAQ)

  • The wiki will output a <link> which references the traditional /favicon.ico, at the root URL path of your site. (Some browsers will look there even without the <link>, others require it.)
  • You can simply replace the favicon.ico image file at the root of your wiki with whatever .ico image file you want.
  • In MediaWiki 1.6.3+ there is a variable in /includes/DefaultSettings.php that can be overloaded in LocalSettings.php$wgFavicon = /path/to/your/favicon.ico

[edit] Getting it to work on GoDaddy

That's not enough for the default configuration of the Linux/Apache servers at GoDaddy. You also need to tweak .htaccess.

# first, enable the processing - Unless your ISP has it enabled already. That might cause weird errors.
RewriteEngine on
# test if rewrite should stop for special directories
RewriteRule ^(images|skins)/ - [L]
# Rewrite rule for the favicon must come before the WikiMedia rule
'''RewriteRule .*.ico$ - [L]'''
#RewriteRule ^wiki/?(.*)$ /index.php?title=$1 [L,QSA]
RewriteRule ^/?(.*)$ /index.php?title=$1 [L,QSA]
#
From: Adding favicon to MediaWiki