Mod rewrite 正在尝试编写mod_重写规则
我已经更改了我的CMS,需要编写一个mod_重写规则来帮助重定向一些旧URL 我想做的是:Mod rewrite 正在尝试编写mod_重写规则,mod-rewrite,url-rewriting,Mod Rewrite,Url Rewriting,我已经更改了我的CMS,需要编写一个mod_重写规则来帮助重定向一些旧URL 我想做的是: 删除“博客/档案” 用破折号替换下划线 将“.html”替换为尾随斜杠 旧链接: http://example.com/blog/archives/the_post_title.html 新链接 http://example.com/the-post-title/ 为了解决第1和第3个问题,我认为类似的方法可能会奏效,但事实并非如此 RewriteRule ^/blog/archives/([A-Za
http://example.com/blog/archives/the_post_title.html
新链接
http://example.com/the-post-title/
为了解决第1和第3个问题,我认为类似的方法可能会奏效,但事实并非如此
RewriteRule ^/blog/archives/([A-Za-z0-9-]+)/?.html$ $1 [L]
谢谢你的建议。关于1和3
RewriteRule ^/blog/archives/(.*?).html$ /$1/ [L,R=permanent]
(请注意,R=永久使用301重定向,该重定向将被缓存很长时间,但会将您的pagerank移动到新URL。使用[L,R]可使用正常重定向)感谢您的启动。我最后的结果是:
RewriteRule^([^.]*)。[^.]*.-$1-$2[N]RewriteRule^([^.]*)$/$1-$2 RewriteRule^/blog/archives/(.*).html$/$1/[L,R=301]