使用 .htaccess 基于日期和名称的友好 URL
我计划将我的博客从 wordpress.com 上切换到在我自己的服务器上托管的我自己的网站上。 当然,我想保留 WordPress 的链接结构,这样 WWW 上指向我博客的链接就不会中断。
所以我的问题是,如何使用 .htaccess 获取以下友好 URL
http://example.com/yyyy/mm/dd/post-name
来映射到某些结构,例如
http://example.com/index.php?page=bla-bla
我的服务器上的结构?
标识符 bla-bla 可以是一个简单的整数 id,还是必须同时包含日期和名称,即 yyyy-mm-dd-post-name?
提前致谢。
编辑:感谢您的快速回复。 不过,对我的问题进行一些补充:我目前没有使用 wordpress.org,因此我没有可以为我生成文件的控制面板。 至少我认为不是。 而且我也不打算在我自己的服务器上使用 WordPress。
I'm planning on switching from having my blog on wordpress.com to having it on my own site hosted on my own server. Naturally I want to preserve the link structure from wordpress so that no links to my blog out there on the WWW break.
So my question is, how do I get the following friendly URL
http://example.com/yyyy/mm/dd/post-name
to map to some structure like
http://example.com/index.php?page=bla-bla
on my server using .htaccess?
Can the identifier bla-bla be a simple integer id, or does it have to include both date and name, that would be yyyy-mm-dd-post-name?
Thanks in advance.
EDIT: Thank you for your quick replies. A few additions to my question though: I'm not currently using wordpress.org, so I don't have a control panel that can generate the file for me. At least I think not. And I'm also not going to use wordpress on my own server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以激活 WordPress 控制面板上的一个设置,以及 WordPress 附带的 .htaccess 文件,使其可以正常工作。 它允许您以任何您想要的方式设置 URL。
There's a setting on the WordPress control panel that you can activate, and a .htaccess file provided with WordPress that lets it work. It lets you set up the URL's any way you want.
WordPress 具有内置的永久链接,并将为您创建适当的
.htaccess
文件。如果您也打算在自己的域上使用 WordPress,那就是了。
WordPress has permalinks built-in and will create an appropriate
.htaccess
file for you.If you're going to use WordPress on your own domain as well, that is.
如果您的主机是 Linux 服务器,则将立即支持重写。 如果您的主机是 Windows 服务器,则需要安装重写插件。
Windows 服务器正在运行 Helicon Tech ISAPI_Rewrite v3,并且在我执行以下操作后,它工作得非常好:
打开插件
正确编写我的重写
将我的 WordPress 永久链接更改为自定义
If your host is a Linux server, the rewrite will be supported out of the box. If you host is a Windows server, you will need a rewrite plugin installed.
Windows server is running Helicon Tech ISAPI_Rewrite v3, and it works perfectly fine after I:
Turned the plugin on
Wrote my rewrite correctly
Changed my WordPress permalinks to custom
您可以根据需要进行以下工作..将其放入 .htaccess 文件中。
要阅读所有详细信息.. 单击此处阅读“友好且漂亮的网址”
You can make following work as you require .. put it in a .htaccess file.
To read all of the details .. click here to read "friendly and pretty urls"