DokuWiki的默认URL看起来很不美观,因此我们建议您以本文介绍的这种方式重写它。

默认的URL

默认情况下,DokuWiki URL如下所示:

http://yourdomain.com/doku.php?id=softwares:skylarkjs

在上面的URL里,页面由参数标识,搜索引擎可能无法将其正确识别为不同的页面。因此,希望如下重写URL。此外,重写的URL易于理解,看起来也很漂亮。

http://yourdomain.com/softwares/skylarkjs URL重写的设置 设置项目

更改以下设置项目。

设置项目设置userewrite1(.htaccess)useslash1(Check on) 变更.htaccess文件

直接在文档根目录下创建.htaccess文件,启动RewriteEngine。

## Uncomment these rules if you want to have nice URLs using ## $conf['userewrite'] = 1 - not needed for rewrite mode 2 RewriteEngine on   RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L] RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L] RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L] RewriteRule ^$ doku.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) doku.php?id=$1 [QSA,L] RewriteRule ^index.php$ doku.php 

另外,根据实际环境,如果DokuWiki的放置位置不直接位于根目录下,则设置RewriteBase的位置。

## Not all installations will require the following line. If you do, ## change "/dokuwiki" to the path to your dokuwiki directory relative ## to your document root. RewriteBase /dokuwiki