更改固定链接
我想将我的永久链接从 /%year%/%monthnum%/%day%/%postname%/ 更改为 /%postname%/
但是当我将以下内容添加到 .htaccess 文件时,帖子没有按照我的方式重定向他们认为:
RedirectMatch 301 /dddd/dd/dd/(.*) /$1
我需要将什么放入 .htaccess 文件中才能使其正常工作?
I want to change my permalinks from /%year%/%monthnum%/%day%/%postname%/ to /%postname%/
but when I added the following to the .htaccess file, posts didn't redirect the way I thought they would:
RedirectMatch 301 /dddd/dd/dd/(.*) /$1
What do I need to put into my .htaccess file to make it work?
My site is http://SweatingTheBigStuff.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为每个人都没有抓住要点 - 我认为 @Daniel 已经更改了他的永久链接,现在想要重定向旧的永久链接。
问题是您的 RedirectMatch 正则表达式仅匹配文字“d”,而不匹配数字。
就我个人而言,我会用这个来代替;
但是,@markratledge 说得对,仅使用帖子名存在问题。
I think everyone is missing the point here - I think @Daniel has changed his permalinks, and now wants to redirect old permalinks.
The problem is your RedirectMatch regex is only matching a literal 'd', not digits.
Personally I would use this instead;
However, @markratledge is right in saying that there are issues with using just the postname.
您无需进入任何代码来更改永久链接;这会改变 WP 核心文件,你会破坏一些东西,并且在升级时你会丢失你的更改。这比这容易得多:转到 WordPress/仪表板/设置/永久链接。如果您的 .htaccess 不可写,您将收到警告。
并且,出于性能原因,不建议在永久链接中仅使用帖子名称: 在永久链接中仅使用帖子名称« WordPress 法典
You don't go into any code to change permalinks; that's changing WP core files, you'll break things and you'll loose your changes on an upgrade. It's much easier than that: go to Wordpress/Dashboard/Setings/Permalinks. If your .htaccess isn't writable, you'll get a warning.
And, using only the postname in permalinks is not recommended for performance reasons: Using only Postname in Permalinks « WordPress Codex
TheDeadMedic 的相关答案,
您可以使用名为 重定向 的插件将旧的永久链接重定向到新的永久链接。
但如果您需要将永久链接从旧版本更改为新版本,请遵循 markratledge 的建议
A relevant answer to TheDeadMedic,
You could use a plugin called Redirection to redirected your old permalinks to new permalinks.
But if you need to change your permalinks from the old version to a new version, then follow markratledge's advice