Switching Redirect Handler in Optimizely CMS (Episerver)

blog header image

This is just a quick code-stub on how to migrate redirects when moving from Verndales Redirect manager to Geta's 404 handler.

I am currently helping a client making some changes on their website (Optimizely/Episerver CMS 11). One of their requests was switching redirect-handling add-on from Verndale's Redirect Manager to the more commonly used Geta 404Handler (formerly BVN 404Handler).

It's pretty straight forward to uninstall one nuget package and install the other, but what about all the existing redirects? Verndales Redirect Manager does support exporting them as a CSV (which seems to work well, except for non ascii characters - but really, those should be avoided in URL's unless encoded anyway) - however Geta 404Handlers import functionality takes an XML. 

Now - it would be really straightforward to write a script to convert one to the other - and I had almost started doing that - but then I noticed that uninstalling the Redirect Manager hadn't cleaned up the database table it uses to store redirects. So - a much simpler solution turned out to simply migrate the contents of that table to the new table introduced by the 404 Handler.

 

Here's the SQL if anyone else find themselves needing it:

INSERT INTO dbo.[404Handler.Redirects] ([Id],[OldUrl],[NewUrl],[RedirectType],[State],[WildCardSkipAppend])

SELECT NEWID(),OldUrl,NewUrl,RedirectType,0,0 from dbo.RedirectManager

 

Recent posts