在wordpress中永久链接更改后,将301从/post.html重定向到/post/


Redirect 301 from /post.html to /post/ after permalink change in wordpress

我将permalink从/post.html更改为/post/

我在.htaccess:中使用了此代码

RedirectMatch 301 /(.*)'.html http://example.com/$1

帖子重定向效果很好,但如果我去主页,我会看到http://example.com/index出现404错误

我该如何修复?

您可以使用negative lookahead来避免匹配index:

RedirectMatch 301 ^/((?!index).+?)'.html$ http://example.com/$1