如何将path映射到Apache中的path.html?

我的旧网站是dynamic的,所有的固定链接都是这种forms:
http://wangling.me/2000/01/file或http://wangling.me/2000/01/file/

现在我刚刚重build我的网站与静态HTML文件,所以永久链接变成:
http://wangling.me/2000/01/file.html

所以我想把旧的永久链接映射到新的永久链接上。 我在/etc/apache2/sites-enabled/wangling.me写了这个:

 <VirtualHost *:80> ServerAdmin xxx ServerName wangling.me ServerAlias *.wangling.me DocumentRoot doc_root RewriteEngine On RewriteCond /$1 !-d RewriteCond /$1 !-f RewriteCond /$1.html -f RewriteRule ^/([^.]+?)/*$ /$1.html </VirtualHost> 

但它不起作用。 这里是相关的日志:

[Sat Jan 19 00:49:01 2013] [error] [client 24.12.163.253]文件不存在:doc_root / 2012/05 / xyz

所以似乎没有使用RewriteRule 。 我知道我的configuration一定有什么问题,因为我甚至不知道RewriteRule Pattern Substitution究竟是什么RewriteRule Pattern Substitution 。 是绝对URL( http://wangling.me/2012/05/xyz ),相对URL(2012/05 / xyz),绝对文件path(doc_root / 2012/05 / xyz)还是相对文件path(2012 / 05 / XYZ)?

通过尝试错误,我发现PatternRewriteRule Pattern Substitution相对URL(/ 2012/05 / xyz)。 所以正确的configuration是:

 <VirtualHost *:80> ServerAdmin xxx ServerName wangling.me ServerAlias *.wangling.me DocumentRoot doc_root RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/$1 !-d RewriteCond %{DOCUMENT_ROOT}/$1 !-f RewriteCond %{DOCUMENT_ROOT}/$1.html -f RewriteRule ^/([^.]+?)/*$ /$1.html </VirtualHost>