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
Post a Comment