SiobhanElara
asked on
What's wrong with this web.config regex?
I have a web.config file with the following rule in it:
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!
<rule name="redirectStaticFileRequestsToDownloadHandler" stopProcessing="true">
<match url="board\/([0-9]+)\/boarddocs\/([^/]+)?$" />
<action type="Redirect" url="/download?filename={R:2}" appendQueryString="false" />
</rule>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER