url rewriting - Regex to match single folder in url for web.config URL rewrite -


we use rather rubbish regex (evidently) match usernames after url rewrite them profile page.

<rule name="profiles" stopprocessing="true">                 <match url="(?:\w|[-_.])+" ignorecase="false" />                 <conditions logicalgrouping="matchall" trackallcaptures="false">                     <add input="{document_root}/{r:0}" matchtype="isfile" negate="true" />                     <add input="{document_root}/{r:0}.php" matchtype="isfile" negate="true" />                     <add input="{document_root}/{r:0}" matchtype="isdirectory" negate="true" />                 </conditions>                 <action type="rewrite" url="/profile.php?username={r:0}" appendquerystring="true" />             </rule> 

i've realised matches way more required , broken images / urls trying load profile page too.

i'm after regex match.

/myusername /myusername/ 

allowing alphanumeric , underscores not additional slashes...

e.g. /qweqwe/qweqwe fail.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -