开发者

htaccess regex, allow underscores

开发者 https://www.devze.com 2023-04-12 01:00 出处:网络
Here is our current regex: RewriteRule ^share/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ /v.php?v=$1&hash=$2 [L]

Here is our current regex:

RewriteRule ^share/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ /v.php?v=$1&hash=$2 [L]

This isn't allowing underscores "_" - how do we get this to all开发者_开发百科ow underscores?

Thank you


You can shorten your regex like this as well. Now this will allow _ also. \w is shorthand for [a-zA-Z0-9_]

RewriteRule ^share/([\w-]+)/([\w-]+)/?$ /v.php?v=$1&hash=$2 [L]


By adding _ to both expressions within the braces []:

RewriteRule ^share/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/?$ /v.php?v=$1&hash=$2 [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号