本文介绍了Apache URL重写UUID v1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何重写36个字符的 v1 UUID 精确地使用RewriteRule进行最大检查?
How do you rewrite a 36 character v1 UUID precisely with maximal-checking using RewriteRule?
UUID() returns a value that conforms to UUID version 1 as described in RFC 4122. The value is a 128-bit number represented as a utf8 string of five hexadecimal numbers in aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee format:
请提供比这更好的东西:RewriteRule ^([A-z0-9\-]{36})$ index.php?uuid=$1 [L,QSA]
Please give something better than this:RewriteRule ^([A-z0-9\-]{36})$ index.php?uuid=$1 [L,QSA]
推荐答案
您可以尝试:
^[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}$
上述正则表达式的解释:
-
^, $
-分别代表行的开始和结束. -
[a-fA-F0-9]{8}
-根据文档; 作为包含五个十六进制数字的utf8字符串;因此最好只允许使用十六进制字符.所以;-
之前的第一个字符串是8个字符的十六进制值. -
(?:[a-fA-F0-9]{4}-){3}
-表示一个非捕获组,匹配4个十六进制字符,后跟一个-
,整个模式精确地重复3次. -
[a-fA-F0-9]{12}
-精确表示十六进制字符12次. -
$0
-对于匹配部分,您可以使用第0个捕获组,因为没有特殊捕获.
^, $
- Represents start and end of the line respectively.[a-fA-F0-9]{8}
- According to the docs; as a utf8 string of five hexadecimal numbers; so it is good to allow only hex characters. Therefore; first string before-
is 8 characters long hex value.(?:[a-fA-F0-9]{4}-){3}
- Represents a non-capturing group matching hex characters 4 times followed by a-
and the whole pattern repeats exactly 3 times.[a-fA-F0-9]{12}
- Represents hex characters exactly 12 times.$0
- For the matching part you may use 0th captured group since there is no special capturing.
这篇关于Apache URL重写UUID v1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!