Htaccess 如何将旧 Url 重定向到新 url 以获取新字符并删除新 url 中间的斜线

Htaccess Howto Redirect old Url to new url that get new charater and remove slash in middle of new url

我对 htaccess 重定向有疑问。
都是这样的link:abc.com/cate/yyyy/mm/yyyy_postname
像这样重定向到 link:abc.com/post-yyyymm/postname

我试过这个:
RedirectMatch 301 ^cate/([0-9]{4})/([0-9]{2})/([0-9]{4})_(.*)$ post-([0-9]{4})/([0-9]{2})/$1

但它不起作用。 请帮助我,非常感谢。

您必须在规则的 RHS 上使用反向引用:

RedirectMatch 301 ^/cate/([0-9]{4})/([0-9]{2})/([0-9]{4})_(.*)$ /post-/

感谢 Anubhava,

你的帮助很有用。
虽然它没有重定向到正确的 url 结果。
它重定向到:acb.com/post-yyyy/mm/yyyy_

但它帮助我更深入地了解如何使用您的帮助。
我试着这样改变:
RedirectMatch 301 ^/cate/([0-9]{4})/([0-9]{2})/([0-9]{4})_(.*)$ / post-$1$2/$4
哈哈,太疯狂了,那个工作。
它完全从 link 重定向:acb.com/cate/yyyy/mm/yyyy_postname
至 link:acb.com/post-yyyymm/postname

再次感谢 Anubhava。