301 Redirect reg expression in htaccess

丶灬走出姿态 提交于 2020-01-05 06:57:59

问题


I'm trying to redirect http://www.domain.com/post/155851321646/post-slug

to http://www.kaleandcaramel.com/post-slug

(this is actually redirecting old Tumblr URLs to Wordpress URLs)

the closest I came was this:

RewriteRule ^/?post/([0-9]+).(.*?)$ http://www.domain.com/$2 [L,R=301]

but it's not working.


回答1:


Use this instead:

RewriteRule ^post/[0-9]+/([^/]+)$ http://www.domain.com/$1 [L,R=301]

Let me know any problems.



来源:https://stackoverflow.com/questions/42035836/301-redirect-reg-expression-in-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!