I need a regex (to be used in .htaccess) with the following attributes, capturing up to a three digit number and the text following it:
Match:
/1-my-blog-post/
/100-another-blog-post/
Do not match:
/1/
/100/
So far I have:
RewriteRule ^(\d{1,2,3}\w+)/$ /post.php?s=$1 [L]
Thanks in advance because it’s really bugging me!
I see some problems in your regex
\d{1,2,3}has to be\d{1,3}you just give the min and the max amount\wincludes also numbers and_but not-Maybe a better solution would be
See it here online on Regexr
[a-zA-Z-]is a character class that matches a character from what is defined inside. I don’t know if the letter range a-zA-Z is fine for you, but you can add any character you want to match into the class like this[a-zA-ZöäüÖÄÜ&?-]