Help with a Regular Expression for IIRF

Hi,

I'm using IIRF 2.1 to handle my urls with IIS.

I'm trying to build a rule to access a particular page:

URL: http://www.mysite.com/username
RULE: RewriteRule  ^/(\[a-z|A-Z|0-9]+)$ /subscribers/profile/?screenNameProfileView=$1

What should be the correct regex so the rule only consider usernames with these characters: A-Z, a-z, 9-0 and _, and avoid urls/usernames with /, ., and ?

Thanks!
HectorVazquezAsked:
Who is Participating?
 
käµfm³d 👽Commented:
The vertical bars are literal (and redundant) inside your character class. You can safely trim the class to be:

[a-zA-Z0-0_]

Open in new window


which could also be represented by:

\w

Open in new window


As a whole, try:

RewriteRule  ^/(\w+)$ /subscribers/profile/?screenNameProfileView=$1

Open in new window


or

RewriteRule  ^/([a-zA-Z0-9_]+)$ /subscribers/profile/?screenNameProfileView=$1

Open in new window


and avoid urls/usernames with /, ., and ?

I'm not sure what you mean here when you say "avoid."
0
 
HectorVazquezAuthor Commented:
Thanks, I didn't want that strings with dots or slashes be considered by the rule.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.