[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

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!
0
HectorVazquez
Asked:
HectorVazquez
1 Solution
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now