English 中文(简体)
需要关于Apache htaccess重定向规则的帮助
原标题:
  • 时间:2009-04-27 09:01:10
  •  标签:

I need to redirect from path

 /articles/20090425-swine-flu-kills.html

to

 /2009/04/swine-flu-kills.html

在原始路径中,文章后面的数字是以yyyymmdd格式表示的日期。需要将其转换为新路径中的"/yyyy/mm/"格式。

I suppose need some regex but I am not sure how. Would appreciate help. Thanks

问题回答
RewriteRule ^articles/(d{4})(dd)dd-(.+)$ /$1/$2/$3

会是一个更好的解决方案。

请试试这个:

RewriteRule ^articles/(d{4})(dd)dd-(.*)$ /$1/$2/$3

这个匹配。

  • ^articles/: Strings starting with "articles/"
  • (d{4}): 4 digits into $1 (the year)
  • (dd): 2 digits into $2 (the month)
  • dd-: 2 digits & dash (edit: missed the leading dash)
  • (.*)$: The rest of the URL into $3




相关问题
热门标签