将.html添加到URL的末尾

问题描述 投票:3回答:2

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

/年/月/日/标题

但我想将其重定向到

/year/month/大约/title.HTML

而且我无法弄清楚如何使用mod_rewrite来做到这一点。

有人有任何想法吗?

wordpress url mod-rewrite jekyll
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。


0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.