Regex 301重写规则在OpenLiteSpeed中工作得非常完美,但只有95%的时间如此
此Wordpress安装以前的永久链接结构为Regex 301重写规则在OpenLiteSpeed中工作得非常完美,但只有95%的时间如此,regex,.htaccess,mod-rewrite,http-status-code-301,litespeed,Regex,.htaccess,Mod Rewrite,Http Status Code 301,Litespeed,此Wordpress安装以前的永久链接结构为year/mo/day/post name,但后来更改为仅使用post name。这个301重写规则被添加到htaccess的顶部,在大多数情况下效果很好,但在几个链接上仍然失败,在URL中留下了day值 RewriteRule ([0-9]{4})\/([0-9]{2})\/(.*) domain.com/$3 [R=301,L] 我不知道是什么原因导致了这种情况,大多数人都像预期的那样重定向到了domain.com/post name,但也有一些
year/mo/day/post name
,但后来更改为仅使用post name。这个301重写规则被添加到htaccess的顶部,在大多数情况下效果很好,但在几个链接上仍然失败,在URL中留下了day值
RewriteRule ([0-9]{4})\/([0-9]{2})\/(.*) domain.com/$3 [R=301,L]
我不知道是什么原因导致了这种情况,大多数人都像预期的那样重定向到了domain.com/post name,但也有一些人返回到了domain.com/08/post name
正则表达式是否存在被忽略的问题?如果您的所有帖子都是相同的格式,如
/2020/01/01/post name
然后尝试使用
RewriteRule ([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.*) https://example.com/$4 [R=301,L]
RewriteRule ([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.*) https://example.com/$4 [R=301,L]
RewriteRule ([0-9]{4})\/([0-9]{2})\/(.*) https://example.com/$3 [R=301,L]
如果您混淆了/2020/01/01/post name
和/2020/01/post name
然后尝试使用
RewriteRule ([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.*) https://example.com/$4 [R=301,L]
RewriteRule ([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/(.*) https://example.com/$4 [R=301,L]
RewriteRule ([0-9]{4})\/([0-9]{2})\/(.*) https://example.com/$3 [R=301,L]
你的意思是“domain.com/08/post-name”没有重定向,或者“/2020/08/08/post-name”重定向到“/08/post-name”?@qtwrk抱歉,这是第二个。“/2020/08/08/post name”正在重定向到“/08/post name”