Link to home
Start Free TrialLog in
Avatar of SiobhanElara
SiobhanElaraFlag for United States of America

asked on

What's wrong with this web.config regex?

I have a web.config file with the following rule in it:

<rule name="redirectStaticFileRequestsToDownloadHandler" stopProcessing="true">
       <match url="board\/([0-9]+)\/boarddocs\/([^/]+)?$" />
      <action type="Redirect" url="/download?filename={R:2}" appendQueryString="false" />
</rule>

Open in new window


If anyone tries to access a file from a URL like "board/[any number]/boarddocs/[any string]" it will redirect them to "/download?filename=[that second string from the URL example]". I've run my code through http://www.regexr.com/ and it says it should be capturing group #2. I tested replacing {R:2} with {R:1} and it redirects to the first captured string ([any number]) like expected.

What am I doing wrong in trying to reference that second string? Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Dr. Klahn
Dr. Klahn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SiobhanElara

ASKER

Thanks, folks! Changing to .* solved the problem, including any slashes being passed along.