Help with a Regular Expression for IIRF


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

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

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 ?

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:


Open in new window

which could also be represented by:


Open in new window

As a whole, try:

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

Open in new window


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."
HectorVazquezAuthor Commented:
Thanks, I didn't want that strings with dots or slashes be considered by the rule.

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.