Mod rewrite 在Apache中设置重写规则

Mod rewrite 在Apache中设置重写规则,mod-rewrite,url-rewriting,Mod Rewrite,Url Rewriting,我需要转换以下URL结构: http://www.example.com/forums/attachments/peasgai-emagazine/277230d1518788091-peasgai-emagazine-february-2018-peasgai-emagazine-feb-2018.pdf 对下列事项: https://www.example.com/community/attachments/277230/ 因此,基本上,直到第一个字母(277230 d1518788

我需要转换以下URL结构:

 http://www.example.com/forums/attachments/peasgai-emagazine/277230d1518788091-peasgai-emagazine-february-2018-peasgai-emagazine-feb-2018.pdf
对下列事项:

 https://www.example.com/community/attachments/277230/
因此,基本上,直到
第一个字母(277230 d1518788091)
的第一个数字是
ID
我必须转换成新的
URL
格式

有什么建议吗

RewriteRule ^attachments/[^/]+/([0-9]+)d[0-9]+-.+$ /community/attachments/$1/ [R=301,L]
成功了