3

我目前正在使用 Wordpress 作为博客平台,但我想更改为使用 Jekyll 来生成静态页面。在 Wordpress 上,我的 URL 使用以下格式:

/年/月/日/标题

但我想将其重定向到

/年/月/日/title.html

我不知道如何使用 mod_rewrite 做到这一点。

有人有什么想法吗?

4

2 回答 2

3
RewriteEngine On
# Only if the URI is not a normal file
RewriteCond %{REQUEST_FILENAME} !-s 
# ... or a symbolic link
RewriteCond %{REQUEST_FILENAME} !-l 
# ... rewrite everything that ends on .html to the stripped down URL
RewriteRule (.+)\.html$ $1 [L]
# Alternatively, if you want to be more specific about the scheme, you can use this
# RewriteRule ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)\.html$ $1/$2/$3/$4 [L}

上面应该给你一些关于如何正确地将 URL 重写为你想要的方案的指示。此示例透明地将所有以 .html 结尾的内容(实际文件除外)重写为相同的 URL,而没有附加 .html。

于 2010-01-15T12:05:32.473 回答
0

我相信您可以转到管理→设置→永久链接并将永久链接设置为自定义,其值为:

/%year%/%monthnum%/%day%/%postname%.html

于 2010-01-15T12:44:40.507 回答