匹配最后一次出现的4位数字htaccess重写 [英] Match last occurence of 4 digits htaccess rewrite
本文介绍了匹配最后一次出现的4位数字htaccess重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我可以使用哪种正则表达式来匹配URL中一组4位数字的最后一次出现.
I'm wondering what sort of regex I could use to match the last occurence of a set of 4 digits in my url.
我的网址格式如下
/ARTIST/ALBUM-4 DIGITS-EXTRA STUFF
在URL中,"4位数字"将是最后可能出现的4位数字.问题是ALBUM可能包含4位数字的集合,因此它需要与URL中最后出现的匹配.
In the url, "4 DIGITS" will be the last possible occurence of 4 digits together. The thing is the ALBUM may contain sets of 4 digits, so it needs to match the last occurrence in the url.
基本上,我需要遵循以下重写规则
Basically I need my rewrite rule to act as follows
RewriteRule ^(.*)/(.*)-(.* MATCH LAST OCCURENCE OF 4 DIGITS)-(.*)?$ album.php?artist=$1&album=$2&releaseyear=$3&EXTRA=$4
有什么办法吗?
推荐答案
我会使用以下规则:
RewriteRule ^(.*)\/(.*)-(\d{4})(?:-(.*))?$ album.php?artist=$1&album=$2&releaseyear=$3&EXTRA=$4
Try it
这篇关于匹配最后一次出现的4位数字htaccess重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文