我更改了我的 CMS,需要重定向一些旧 URL。
我想做的是:
- 删除“博客/档案”
- 用破折号替换下划线
- 用斜杠替换“.html”
旧链接:
http://example.com/blog/archives/the_post_title.html
新链接
http://example.com/the-post-title/
我已经写过,它在某一时刻工作,但我现在收到 500 个错误。
RewriteRule ^([^_]*)_([^_]*_.*) $1-$2 [N] #Replace "_" with "-" loop until one left
RewriteRule ^([^_]*)_([^_]*)$ /$1-$2 #Replace the last underscore
RewriteRule ^(.*?).html$ /$1/ [L,R=301] #Strip the ".html" and use the filename as the url, note this as "permanently moved" (301)
知道为什么我会收到服务器错误吗?