I need to redirect 000s of inbound URLs that are structured like this: sitename/yyyy/mm/dd/section/title.asp to this: sitename/section/id/title/. Clearly a redirect map is the only sensible way to do this!
My URL Rewrite module is installed and working and I've set up this test rule directly in my webconfig file, which works perfectly:
<rule name="Test Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{REQUEST_URI}" pattern="/2012/10/10/opinion/sample-title.asp" />
</conditions>
<action type="Redirect" url="/opinion/6716/sample-title/" />
</rule>
So the redirect works, plus these are all static redirects - no query strings. But when it comes to doing the same thing using a redirect map, nothing I've tried works.
So first, I've followed the instructions and defined the location of my redirect map thus in webconfig:
<rewriteMaps configSource="rewritemaps.config"></rewriteMaps>
The map will contain entries exactly as above, so, for example:
<rewriteMaps>
<rewriteMap name="Redirects">
<add key="/2012/10/10/opinion/sample-title.asp value="/opinion/6716/sample-title/" /
</rewriteMap>
</rewriteMaps>
I've also put in some really simple ones to test, so, for example, <add key="/test.htm" value="/test2.htm" />
The rule in my webconfig file to use the map is this:
<rule name="Redirect Rule" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{C:1}" appendQueryString="false" />
</rule>
But I can't get a single redirect to work from this map - not even the simplest http://sitename/test.htm to http://sitename/test2.htm.
So is there something wrong with this rule? I've tried <match url="(.*)" /> and <match url=".*" />. For the input part of the rule, I've tried URL, REQUEST_URI, REQUEST FILENAME (removing the initial slash from the entries in the rewrite map), each time restarting
the server / app pool, but WHATEVER permutations I try, NOTHING happens. (ie there's is no sign of any redirection activity whatsoever) - the {C:1} part just seems to be getting ignored.
But as I said to begin with, when I set up the same rule in the webconfig file itself, it works . . . . (BTW, I've tried defining the map inside the websconfig file, too, and that doesn't work either)
I've also set up failed request tracing, but there don't seem to be any errors appearing in the rewrite module. It's as if the redirect map is just being ignored.
I'm at my wits end with this. Can anyone suggest what's wrong?