« IPtables 规则错误导致DNS查询失败之解决办法 | Main | Acrobat + MS word + HyperSnap = 文档利器 »
August 20, 2006
配置Mediawiki支持短URL
为了美化URL,今天花了巨多时间在这个看似简单又讨厌的问题上面。中午觉也没有睡。首先来个惯例的Step by step 安装步骤吧。
1.下载mediawiki
由于测试机是php4.3.9,为了不麻烦,偷懒用了个1.6.8的版本,支持php4.x
2.解包
tar xfz mediawiki-1.6.8.tar.gz
mv mediawiki-1.6.8 /var/www/extsuite/mediawiki
3.设计站点URL
计划要用http://wiki.extmail.org来访问整个wiki,因此所有的http://wiki.extmail.org/index.php?title=article_title 需要影射成为http://wiki.extmail.org/article_title
4.参考
http://meta.wikimedia.org/wiki/Using_a_very_short_URL
注意这个链接访问不了,必须使用代理才能访问,在这里,感叹一下我们的自由是多么脆弱。一点小小信息都不能看,Damn it :-(
5.实施
Apache的虚拟主机配置:
ServerName wiki.extmail.org
DocumentRoot /var/www/extsuite/mediawiki
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
# avoid execution of PHP scripts in upload directory
AddType text/plain .php
AddType text/plain .phps
chmod a+w config
然后访问http://wiki.extmail.org/config/
配置完毕,生成数据库后:
mv config/LocalSettings.php .
配置LocalSettings.php
正常默认就是下面:
$wgScriptPath = "";
$wgScript = "$wgScriptPath/";
$wgRedirectScript = "$wgScriptPath/redirect";
然后修改下面:
$wgArticlePath = "$wgScriptPath/$1";
include "extensions/GeshiHighlight.php";
6.配置使用/wiki/的方法
希望访问wiki 的url为http://www.extmail.org/wiki/xxx
1-5的步骤略去。给出apache 的配置:
ServerName www2.extmail.org
DocumentRoot /var/www/extsuite/html
Alias /mediawiki /var/www/extsuite/mediawiki
Alias /wiki /var/www/extsuite/mediawiki/index.php
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?title=$1 [L,QSA]
LocalSettings.php:
$wgScriptPath = "/mediawiki";
$wgScript = "/wiki";
$wgRedirectScript = "/wiki/redirect";
$wgArticlePath = "$wgScript/$1";
include_once("extensions/GeshiHighlight.php");
唯一的缺点是在登陆或退出时,URL是http://www2.extmail.org/wiki?title=xxx&xxxx=xxx
因为apache配置里将/wiki => index.php了,所以wiki?参数就和index.php?参数一致了。嘿嘿。
Posted by hzqbbc at August 20, 2006 05:02 PM