I'm in the process of migrating some Sharepoint sites from one farm to another farm. It's a little more complicated, but for simplicity sake...
What I'd like to maintain is old URLs that people have for these sites, documents, etc. and the IIS URL Rewrite Module seems like a good way to go.
Here's an idea of what the structure is:
_______________________ _______________________
|oldfarm.company.com**| |newfarm.company.com**|
|oldsitecollection** | |newsitecollection** |
|subsitename | |subsitename |
|... | |... |
|_____________________| |_____________________|
** = changes, everything else remains the same, URLwise.
On the "newfarm" I have extended the web application to respond to "oldfarm.company.com", and that web application has a URL Redirect Rule that redirects http://oldfarm.company.com/oldsitecollection/... to http://newfarm.company.com/newsitecollection/...
That works great for the vast majority of what I'm trying to do.
What I'm having difficulty with is rewriting QUERYSTRING values. Sharepoint's Office Document Viewers contain path information in the QUERYSTRING and that's what I need to change.
Here is an original URL sample: http://oldfarm.company.com/oldsitecollection/subsitename/_layouts/WordViewer.aspx?id=/oldsitecollection/subsitename/doclib/doc.docx&Source=http%3A%2F%2Foldfarm%2Ecompany%2Ecom%2Foldsitecollection%2Fsubsitename%2Fdoclib%2FForms%2FAllItems%2Easpx&DefaultItemOpen=1
Here is the URL after the redirect (and where I'm stuck): http://newfarm.company.com/newsitecollection/subsitename/_layouts/WordViewer.aspx?id=/oldsitecollection/subsitename/doclib/doc.docx&Source=http%3A%2F%2Foldfarm%2Ecompany%2Ecom%2Foldsitecollection%2Fsubsitename%2Fdoclib%2FForms%2FAllItems%2Easpx&DefaultItemOpen=1
Here is what I need the URL to look like: http://newfarm.company.com/newsitecollection/subsitename/_layouts/WordViewer.aspx?id=/newsitecollection/subsitename/doclib/doc.docx&Source=http%3A%2F%2Fnewfarm%2Ecompany%2Ecom%2Fnewsitecollection%2Fsubsitename%2Fdoclib%2FForms%2FAllItems%2Easpx&DefaultItemOpen=1
I have tried using Rewrite Maps because these are not dynamic substitutions, but I cannot get them to modify the QUERYSTRING.
Here's an example of the rewrite rule I'm working on:
<rewrite>
<rewriteMaps>
<rewriteMap name="WordViewer">
<add key="id=/oldsitecollection" value="id=/newsitecollection" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Rewrite rule1 for WordViewer">
<match url=".*WordViewer.aspx" />
<conditions>
<add input="{WordViewer:{QUERY_STRING}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>