IIS URL Rewrite to Redirect PDF File (Regex) -
server: iis 8
i have url rewrite rile redirect pdf files page handle additional processing. works except when pdf files have special characters or spaces in them, destination page gets characters right of spaces or special characters.
as example, see following filename:
receipt - hard drive.pdf
the receiving page (/getfile/?pdf=) receive only
drive.pdf
i have tried various regex methods people regex knowledge pretty terrible.
how can write 'match url' accept filenames (at least accepted windows, such filenames underscores, dashes, spaces, single quotes, double quotes, pound signs, etc). there way write universal passes all characters regardless of are, since want match *.pdf? current rule below.
<rule name="pdf rewrite" stopprocessing="true"> <match url="([\w-]+)\.pdf$" /> <action type="redirect" url="/getfile/?pdf={r:1}.pdf" logrewrittenurl="true" redirecttype="temporary" /> </rule>
you may use
<match url="(.+)\.pdf$" />
the .+
matches one or more characters other line break chars many possible.
Comments
Post a Comment