我已更改了CMS,需要重定向一些旧网址。
我想做的是:
旧链接:
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)
知道我为什么会收到服务器错误吗?
答案 0 :(得分:0)
您可以尝试将其替换为:
RewriteRule ^(.*)_(.*)$ /$1-$2
RewriteCond %{REQUEST_URI} !_
RewriteRule ^blog/archive/(.*).html$ /$1/ [L,R=301]