This might not be the exact answer to your problem, but - although it has annecdotal character - it might help you find the solution.
I was working on a Orchard site that had
- a lot of pages
- a lot of html links to other pages on the site
- a lot of custom link items in the navigations (to link to certain anchors inside a target page, etc.)
Shortly before we planned to delpoy the website, it was decided to change the URLs of the most prominent pages for SEO reasons from http://www.example.org/orchard/products/category-name/product-name
to http://www.example.org/orchard/shop/category-name/product-name-keyword-anotherkeyword
(gotta love SEO...)
Doing this manually would have taken ages. Changing the URL in the content item itself would be easy (but doing that on ~20 items still would take some time), but changing all those <a href
s in all the 120+ content items, and all the custom links in the 5 navigations (5 languages) would simply be impossible.
So the only feasable way seemed to be database manipulation.
I used MS SQL Server Management Studio
to export all tables in the Orchard database to individual .sql files. I then used Notepad++
to search for all files that contained the partial string /products/category/product-name
and wrote down the table names and the field name (usually Text
or Data
)
In this case the results were in the following tables:
- Common_BodyPartRecord.Table
- Orchard_Framework_ContentItemRecord
- Orchard_Framework_ContentItemVersionRecord
To search-replace
a partial string in SQl you use the replace
function, and because of the datatype of the table fields the orchard stores the data in you have to cast strings. The resulting SQL queries look like this:
update [Orchard_Live].[dbo].[Common_BodyPartRecord]
set Text = cast(replace(cast(Text as nvarchar(max)), N'/products/category/product-name', N'/shop/category-name/product-name-keyword-anotherkeyword') as ntext)
where cast(Text as nvarchar(max)) LIKE N'%/products/category/product-name%'
update [Orchard_Live].[dbo].[Orchard_Framework_ContentItemRecord]
set Data = cast(replace(cast(Data as nvarchar(max)), N'/products/category/product-name', N'/shop/category-name/product-name-keyword-anotherkeyword') as ntext)
where cast(Data as nvarchar(max)) LIKE N'%/products/category/product-name%'
update [Orchard_Live].[dbo].[Orchard_Framework_ContentItemVersionRecord]
set Data = cast(replace(cast(Data as nvarchar(max)), N'/products/category/product-name', N'/shop/category-name/product-name-keyword-anotherkeyword') as ntext)
where cast(Data as nvarchar(max)) LIKE N'%/products/category/product-name%'
I had to do this for every URL that had to be changed. Took quite a while, but still beat manually changing everything by far. Maybe this "workflow" can help with your problem, too.