SharePoint URL Redirector available for download on CodePlex

On CodePlex: http://rdacollaboration.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28073

So, sometime last year, RDA engaged in a project with a client to migrate a SharePoint 2003 environment to SharePoint 2007. After some initial planning, we determined that a one-time content database migration was going to be the best approach. However, we had a few complications to consider:
  1. When using this upgrade path, SharePoint 2007 takes some liberties with the URL structure of the sites once the databases are attached to the 2007 environment and upgraded. For example, the familiar "C" addresses of 2003 (Ex: http:\\sharepoint2003\C10\HR) were converted to "Topics" (Ex: http:\\sharepoint2003\Topics\HR).
  2. The client was not incredibly happy with their existing site taxonomy in general and wanted to take the opportunity to rearrange their sites as part of the upgrade.

The problem: The project would be considered a failure by the user community if everyone lost their IE favorites and links already embedded in content. We needed a solution to redirect URL requests from the old URL schema to the new locations.

Todd Klindt has an excellent article on different options for implementing redirection in SharePoint. Check it out here: http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=48

Upon reviewing the various options, I decided that none of the techniques would really work for the size and scope of what was needed. We needed:

  1. A way to define redirection farm-wide - for hundreds of sites. Not just one-off rules for redirecting single pages or sites.
  2. A way to redirect all URLs for ALL content under a site - not just the first page of the site. If the user linked to an image 15 folders deep in a site, that link should still function even if the site is moved or renamed.
  3. Immediate redirection - no 5 second wait for redirection pages. Ideally, the user shouldn't even realize they've been redirected.
So, I decided to build the SharePoint URL Redirector. I've released a binary, documentation and source code on CodePlex here:

http://rdacollaboration.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28073

The SharePoint URL Redirector features:
  • Regular Expression based rules - Permits massive flexibility in redirecting content requests. Entire sites of content to be redirected to other locations in a single rule. Not just single pages.
  • Test Driven Design - Built-in testing interface simplifies the design and upkeep of redirection rules. Immediately see conflicting rules or URLs that are no longer valid.
  • Centralized Rule Management - UI for maintaining rules is integrated into SharePoint Central Administration.
  • Immediate Redirection - Redirection is immediate. Users typically don't even notice that they've been redirected from their original URL. No annoying "You'll be redirected in 5 seconds" pages.
  • Scalable - Creatively caches rules and translations to maintain page-load performance. Has been tested with hundreds of redirection rules utilized with no perceived difference in page load times.
  • Ability to copy rules - Rules can easily be copied to other SharePoint web applications.
  • Chainable - Complex redirection can be performed by chaining multiple rules.


In the end, using this solution, we successfully provided seamless redirection for all content in over 350 sites (and many many more sub-sites). Most user's have never noticed a difference. Since then, several other RDA'ers have utilized it on their projects for other reasons such as:

  • Accommodating Site Moves - If you ever have to relocate a site to a new site collection because it's gotten too large and needs its own content databases, you can redirect the old URL scheme to the new one. No need to have to explain to users why you moved their site and broke their IE favorites.
  • Fill in holes in the URL scheme of your site - For example, if all of your sites are located under http://company.com/sites/* (a wildcard managed path), then there is no page directly under http://company/sites. Redirect that URL to a site directory or home page for a better overall experience for users of your environment.
  • Vanity URLs - Configured properly, you could setup a vanity URL at http://finance.company.com that redirects the user to the real site at http://depts.company.com/sites/finance. Sometime soon, I'll post an article on exactly how to do this.

So, please check it out. I highly suggest reading the documentation posted on CodePlex with the tool, and utilizing the test-driven approach to defining rules. It's really fun to see the green indicator light up after you successfully define and test a rule! Also, if you're unfamiliar with Regular Expression syntax, a pretty good overview can be found here: http://www.codeproject.com/KB/dotnet/regextutorial.aspx

31 comments:

Paul said...

Hmm, I just get the dreaded Unknown Error (Go Back To Site) page when I click my newly created URL Redirector Application Management link...:(

Used the install.cmd batch file, and it added & deployed ok, judging by the new link in app management.

Any thoughts?

P.

Jason Barron said...

Couple of things to try:

- Execute 'stsadm -o execadmsvcjobs' and retry.

- Check to see if you have access to write to '\Inetpub\wwwroot\wss\VirtualDirectories\[Web App]\_app_bin'.

Let me know if either of those work.

Thanks!

Anonymous said...

i deployed the redirector ok but when i try to use it the is the following message.



The 'URL Redirector' feature is not activated for this Web Application. Changes below will not have an effect.

Jason Barron said...

Yes - you need to go out to "Central Admin -> Application Management -> Manage Web Application Features" and activate the "URL Redirector" feature for whichever web apps you want to apply redirection rules.

The rule editing screens are accessible for all web apps, but the rules you define will only have an effect for those web apps that have the feature turned on.

Jon said...

Hi Jason;
Thank you for developing this great app.
I'm having a slight problem with it in our production environment though. In Central Admin when I click on the linkk to go to the app I receive the below error meessage. We have 2 web front ends and 2 index server. Central Admin is running on the index server. The permissions have been applied correctly on the _app_bin directory. I also copied a urlmapping.xml file from the dev machine to the prod machines and it will forward correctly using the xml file. I just cannot get the webapp to run correctly.

Any help would greatly be appreciated.

Regards - Jon

The resource object with key 'Title' was not found. at System.Web.Compilation.ResourceExpressionBuilder.ParseExpression(String expression, Type propertyType, ExpressionBuilderContext context)
at System.Web.UI.BoundPropertyEntry.ParseExpression(ExpressionBuilderContext context)
at System.Web.UI.ControlBuilder.FillUpBoundPropertyEntry(BoundPropertyEntry entry, String name)
at System.Web.UI.ControlBuilder.AddBoundProperty(String filter, String name, String expressionPrefix, String expression, ExpressionBuilder expressionBuilder, Object parsedExpressionData, Boolean generated, String fieldName, String formatString, Boolean twoWayBound)
at System.Web.UI.ControlBuilder.PreprocessAttribute(String filter, String attribname, String attribvalue, Boolean mainDirectiveMode)
at System.Web.UI.ControlBuilder.PreprocessAttributes(ParsedAttributeCollection attribs)
at System.Web.UI.ControlBuilder.Init(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs)
at System.Web.UI.ControlBuilder.CreateBuilderFromType(TemplateParser parser, ControlBuilder parentBuilder, Type type, String tagName, String id, IDictionary attribs, Int32 line, String sourceFileName)
at System.Web.UI.ControlBuilder.CreateChildBuilder(String filter, String tagName, IDictionary attribs, TemplateParser parser, ControlBuilder parentBuilder, String id, Int32 line, VirtualPath virtualPath, Type& childType, Boolean defaultProperty)
at System.Web.UI.TemplateParser.ProcessBeginTag(Match match, String inputText)
at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)

Ramu Pulipati said...

Execute "stsadm -o copyappbincontent" on SharePoint server and try again.

Jason Barron said...

Jon - similar to Ramu's suggestion, it sounds like the resource files did not deploy correctly. There are 2 resource files (deployed to '12\TEMPLATE\FEATURES\URLRedirection\Resources'):
- urlredirection.resx
- urlredirection.en-US.resx
These files need to be copied to '12\Resources' and to 'App_GlobalResources' under the IIS directory for Central Admin.

If you copy then over manually, that should resolve your issue. It's tough to say why they didn't deploy correctly in the first place. Is your 'Windows SharePoint Service Timer' service running? You might also check the SharePoint logs for any errors related to the 'RDA - Url Redirection - Deploy Resource Files' job. If you see anything suspicious, post it here.

Jon said...

Thank you Jason and Ramu,
Copying the files from 'App_GlobalResources'

Regards - Jon

Paul said...

Jason, your first suggestion,

'stsadm -o execadmsvcjobs'

did the trick for us; exec'd the command and voila, one working URL Redirector function!

Now to figure out the syntax we need...;¬)

Many thanks,

P.

darsh said...

i have installed the RDA control on my site successfully, its working fine but only with the system account and not with other users. please suggest anything anybody.

its giving me 403 forbidden error when i login with other users

Jason Barron said...

I added a release note about this on the CodePlex site. I think this is the issue your seeing:

"This release requires all users to have read access to the _app_bin directory under the site's virtual directory (ie: C:\Inetpub\wwwroot\wss\VirtualDirectories\[VirtualDirName]\_app_bin). Further, the app pool account for the Web Application needs to have read/write permissions to this same directory."

Brian Denicola said...

Hi. Great addon for SharePoint. I got everything working on my development machine which is only one server. but when I deploy this to my test environment I get an error when deleting a mapping. The error is:

The object with id f4ce992a-e3d6-443e-b859-8f8774a04ee1 does not exist in the configuration store. The object may have been deleted by another operation.

The test environimetn has two servers (one web and one index/central admin).
During the install, I had to copy the UrlMapping file from the Web Application server to the Central Admin server. And when I delete a mapping, it removes it from the UrlMapping on the Central Admin server but not the web server.

Brian

Jason Barron said...

Sounds like it might be permission related. Check which account the SharePoint Timer Service is running under and make sure it has read/write access to the "_app_bin" folder and the UrlMappings.xml file in it, under the Web Application's virtual directories on each server (C:\Inetpub\wwwroot\wss\VirtualDirectories\[VirtualDirName]\_app_bin). Also, check to make sure that all users have read access to that directory and the UrlMappings.xml file.

Respond back if that doesn't get it.

Also, have you extended any of the Web Apps on your test environment into a new zone? If so, it won't copy correctly to the extended zones. That will be fixed in a future version.

Thanks!

Anonymous said...

Thank you for this great redirection tool. I have it working in our production environment with the following original and destination URLs configured: http://(?[^/]+)(?/[\w\W]+)(?/[^\?\$]+)(?\?[^$]+)?
and https://Intranet.DirectRelief.org$site$page$querystring

In Test URL Mappings I pass with green indicators, and in the real world it works perfect. original: http://intranet/pages/default.aspx
destination: https://intranet.directrelief.org/Pages/Default.aspx

The problem is I want to redirect users with the following original URL: https://intranet/pages/default.aspx
destination: https://intranet.directrelief.org/Pages/Default.aspx

when I create the same URL mapping as the one above but change the Original URL to: https://(?[^/]+)(?/[\w\W]+)(?/[^\?\$]+)(?\?[^$]+)?
and leave the destination the same as above: https://intranet.directrelief.org/Pages/Default.aspx
note: I only changed the original URL from HTTPS from HTTP

When I test the URL mapping I get green for the mapping and yellow for the links and it presents the following error "The object with id 47736447-7084-4cc6-81c9-529dd57cfb7c does not exist in the configuration store. The object may have been deleted by another operation."
Finally the pages load but the theme and page layout is drastically wrong. Also, the URL that is returned to me looks like this: https://intranet.directrelief.org/Pages/Default.aspx?&Redirect=5

It looks like it is redirecting 5 times.

Any help is greatly appreciated.
Aaron

Jason Barron said...

Aaron - it appears that the redirection rules are getting into an infinite loop. It short-circuits at 5 loops - which it why you see the Redirect=5. Try changing the Regular Expression on your second rule to match the expected server name (instead of *any* server name) Ex: http://intranet/(?<site>[\w\W]+)... That should prevent the infinite loop. If it doesn't resolve the UI problems, tell me more about your Web App & Alternate Access Mapping config and I will try to help.

As for the error you see on the Test screen: 'The object with id % does not exist in the configuration store', you can ignore that I think. It's an issue I've been investigating with some environments with multiple web front ends. It should work fine in spite of that particular error.

Matty said...

Hi,

I have a question about where the redirection is taking place. Is it at an ISAPI, HTTP, ASP.NET layer or at the web application itself? I am thinking of SEO here.

Thanks

Sean said...

After deploying the solution both using the install.cmd as well as using stsadm...

I receive no errors throughout the process however, I do not see any options for RDA or URL Redirector in Application Management.

Jason Barron said...

Matty - The solution uses an HttpModule (ASP.NET layer) to intercept requests to the web and redirect them. The HttpModule is registered in the web.config for the SharePoint Web Application, so the effect is scoped to whatever is covered by the web.config.

I don't know that much about SEO really, so I'd be interested to hear the ramifications of my approach with respect to SEO.

Jason Barron said...

Sean - the Feature is set to auto-activate on the Central Admin Web Application. Sounds like it may not have for some reason. Take a look at the Web Application Features screen for the Central Admin Web App and see if the "URL Redirector" Feature is activated. If not, activate it and you should see the link show up under Central Admin -> Application Management.

Sean said...

URLRedirector does not appear under the web applications feature management page either. I had checked this initially thinking that it may have simply not activated properly in the first place... No Joy.

Anonymous said...

F5 load balancer doesn't work with URL redirector. Any solutions?

Jason Barron said...

I'm not very in-depth on load balancer configs, but I'll try to help.

If it helps, the URL Redirector is fairly simple in what it's doing. It captures incoming requests, matches the URL against a list of URLs to redirect, and, if matched, redirects them with a 302 redirect to the new URL.

What kind of behavior are you seeing? Have you verified it is working when you don't go through the F5?

Thanks

Josh said...

I'm having an issue redirecting URL's with %20 spaces in them. I've tried an escape character before the % but it still does not work. The weird thing is, when I set up a TEST for it, it succeeds, but from the browser nothing happens.

Jason Barron said...

Josh - If you use a space instead of the '%20' code in your "Original Url", that should work.

I do think you found a little bug in that the "Test" is not functioning exactly like the real redirect for some reason. I'll look into it.

Thanks!

Josh said...

Jason, that seems to have done the trick. Thanks so much. This add-on is amazingly useful.

dunxd said...

I am getting the 403 error. I have checked the _app_bin folder has Read acccess for Everyone, and Read/Read&Execute/List Folder Contents permissions, and App Pool Identity and WSS Timer Service account have all above + Write.

I do not see a UrlMappings.xml file in the _app_bin folder on my WFEs, only the server running Central Admin.

I am running a 3 server farm - 1 CentralAdmin/Index server and 2 WFEs.

dunxd said...

I figured maybe I needed to set up the permissions before deploying the solution, so undeployed, then double checked the permissions and redeployed.

Still, after activating the feature in a Web App, all pages give the 403 error. The UrlMappings.xml file is still missing from the _app_bin folder on the WFEs.

Looking at the Application logs on the WFE, I can see the following related error:

Event Type: Information
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1314
Date: 12/08/2010
Time: 08:46:53
User: N/A
Computer: SI144
Description:
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 12/08/2010 08:46:53
Event time (UTC): 12/08/2010 07:46:53
Event ID: f839cd7e0b6844cab1e7d38f0eb7263c
Event sequence: 2
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/792804208/Root-8-129260728116207758
Trust level: WSS_Minimal
Application Virtual Path: /
Application Path: C:\Inetpub\wwwroot\wss\VirtualDirectories\Intranet80\
Machine name: SI144

Process information:
Process ID: 2172
Process name: w3wp.exe
Account name: CAID\app_pool

Request information:
Request URL: http://intranet/PublishingImages/CA red RGB 78x55.gif
Request path: /PublishingImages/CA red RGB 78x55.gif
User host address: 172.16.1.155
User:
Is authenticated: False
Authentication Type:
Thread account name: CAID\app_pool

Looks like with URL Redirector activated, that the users credentials are not getting passed - could this be caused by the absence of UrlMappings.xml?

Is UrlMappings.xml slow to copy between servers, or is there some other issue preventing that?

Unfortunately I don't have a multi-server farm to test on, and the production server is too busy for much experimentation.

dunxd said...

Looking more deeply at our Sharepoint setup, I noticed that the web app was extended as part of the migration from Sharepoint 2003. That may explain the problem, as there are multiple inetpub folders relating to the web app.

You state above that a future release will support this - but from your blog you appear to be focussed on Sharepoint 2010 now. Will there be a new release of URL Redirector for SP 2007? If not, do you have any advice or pointers on where you were going with development to achieve the planned function to deal with extended web apps?

Jason Barron said...

dunxd - I am planning on releasing an update to both 2007 and 2010. Both would likely include an overhaul to the architecture that would have the rules being stored in a hidden SharePoint List or in the Web Application property bag so that it doesn't have to manage the UrlMappings.xml file on the disk or worry about copying it around to different servers. This should alleviate almost all of the security issues and the issue with extended Web Applications. The only drawback would be that the redirector wouldn't really work outside of SharePoint, but I get the sense that feature is rarely used.

Anonymous said...

Does the current version of redirector (http://rdacollaboration.codeplex.com/releases/view/28073) works with SharePoint 2010


Mohid

Bharat Gupta said...

hello, I have install the solutiona and activate the feature on web applicaiton. I have update settings replaced http://servername/sites1/abc to http://www.abc.com from URLRedirect.aspx page in SharePoint2010. After opening with new URL I am getting windows login prompt but it it not accepting credientials. Please me if I am missing any step.