|
Mailing Lists
|
Home /
Groups /
Regular Expressions (RegEx)
regex for twitter style URL
Hi I am trying to do a mod_rewrite for twitter style username urls to http://myurl.com/andyjarrett would go to http://myurl.com/index.cfm?user=andyjarrett So far I have RewriteRule ^(((?!user|index.cfm))*.?)*$ index.cfm?user=$1 [L,QSA] But this just isnt working. Anyone done this or can help? Thanks, Andy Jarrett www.andyjarrett.co.uk Try this: ^(?!user|index\.cfm)([\w-]+)$ Note that this allows only usernames containing alphanumeric, underscore, and/or hyphen. If usernames allow more characters, or you want to defer validation to the script, you could use something more inclusive (e.g ".+") instead of "[\w-]+", for that part of the expression. Oh and not too sure what the "user" part there is for, but it may need updating if you don't want to block names such as "useredpaint" and similar.
|
May 25, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||