开发者

Regex extract number for RewriteRule

开发者 https://www.devze.com 2022-12-20 11:26 出处:网络
For http://macintosh.local/clientname/102 I can get the numeric reference (3 digits) like this: 开发者_JAVA技巧RewriteRule ^[^/]+/([0-9]{3}+)/?$ album.php?ref=$1 [L]

For http://macintosh.local/clientname/102

I can get the numeric reference (3 digits) like this:

开发者_JAVA技巧
RewriteRule ^[^/]+/([0-9]{3}+)/?$ album.php?ref=$1 [L]

Now I want to get my reference in my SEO URL:

http://macintosh.local/clientname/102-some-keywords


just replace /? with .*

RewriteRule ^[^/]+/([0-9]{3}+).*$ album.php?ref=$1 [L]


It looks like your existing regex should work just fine. It won't pick up non-numeric characters, after all.

0

精彩评论

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