首页 > IT杂谈 > mediawiki短url的配置

mediawiki短url的配置

2010年4月21日 亲亲宝宝 发表评论 阅读评论
假定安装的路径是:
MediaWiki’s 缺省安装路径像下面这样:

/var/www/localhost/htdocs/mediawiki/w (installed as root user)

MediaWiki’s 缺省访问url是:

http://example.com/w/index.php/Page_title (recent versions of MediaWiki, unless using CGI)

http://example.com/w/index.php?title=Page_title (recent versions of MediaWiki, using CGI)

mediawiki的短url打算像下面这样:

http://example.com/wiki/Page_title (标准访问url 像Wikipedia)

http://wiki.example.com/Page_title (不被推荐)

第一步:在LocalSettings.php文件的最下面添加:

$wgScriptPath = “/w”;         # Path to the actual files. This should already be there

$wgArticlePath = “/wiki/$1”; # Virtual path. This directory MUST be different from the one used in $wgScriptPath

$wgUsePathInfo = true;        # Enable use of pretty URLs

Note that $wgScriptPath should already be set to /w. If it is not (for example, if you’re moving from a different URL scheme), make sure to set it to that.

第二步:编辑httpd.conf增加别名

Alias /wiki /path/to/your/wiki/index.php. 注意 path 是文件在系统的绝对路径! This might be, for instance, Alias /wiki /var/www/w/index.php,

或者 在web的根目录下编辑 .htaccess:

RewriteEngine On

RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]

RewriteRule ^wiki/*$ /w/index.php [L,QSA]

RewriteRule ^/*$ /w/index.php [L,QSA]

RewriteRule defines virtual paths and how they should be rewritten; in the example above, /wiki/Page will cause /w/index.php?title=Page to be loaded instead.

如果使用的ISAPI_Rewrite,可以使用下面的配置内容:

RewriteCond %{QUERY_STRING} ^action=(.*)$
RewriteRule /wiki/(.*) /51667/index.php\?title=$2&action=$1
RewriteRule ^/*$ /51667/index.php&action=$1

测试访问一下,apache出现错误:

Invalid command ‘RewriteEngine’, perhaps mis-spelled or defined by a module not included in the server configuration

解决办法:

打开httpd.conf ,取消 LoadModule rewrite_module modules/mod_rewrite.so前的注释

分类: IT杂谈 标签: 4,182 次阅读
原文链接:http://www.wenhq.com/article/view_444.html
欢迎转载,请注明出处:亲亲宝宝
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.