IIS URL Rewrite - anchor in input causing strange behaviour.
Hi.
We recently migrated some content on a legacy IIS platform to a SharePoint online instance.
However, there are some documents in the wild & not in our control which contain links to the old IIS site.
We have successfully handled 99% of these using the URL Rewrite module to redirect to the new SharePoint locations.
However, we are seeing some very strange results with some of the input URLs that end in "#_blank".
When these links are clicked on the first time, the target location loads fine. However, if the very same link is clicked on again in the same browser session, then the entire query string is omitted from the target URL.
This happens even when using an incognito browser which cache cleared, etc.
For security reasons I can't put the actual rule here, but it's along the lines of
<rule name="A Rule Name" stopProcessing="true">
<match url="MatchThisSimplePattern" />
<action type="Redirect" url="https://site.sharepoint.com/sites/blah-blah/this/that/AllItems.aspx?id=%2Fsites%2Fstuff%2Dmorestuff%2Fthing%2Fsome%2Fthing%2Epdf&parent=%2Fstuff%2Fmorestuff%2things" appendQueryString="false" />
</rule>
And the URL of the source link is similar to https://domain.com/text/stuff/MatchThisSimplePattern.pdf#_blank
Note, if the source is entered in the browser without the #_blank, the issue goes away. Unfortunately, we can't update the source links we're trying to redirect.
In the above case, the redirect would happen the first time to the full target URL. The second time, everything beyond AllItems.aspx is removed from the target URL.
I've used a test IIS instance to make sure there is only one redirect (or any other) rule in existence, to make sure no other rules are causing any issues.
I can find no help or references to similar problems either in the URL Rewrite documentation, or anywhere else online.
Note, I've also tried adding as a Rewrite map entry, minus the #_blank. This produced the same behaviour.
Thanks
Kevin