« Previous Next »

Not Answered Thread: Dynamically Generate Rewrite Maps?

Last post 05-27-2009 7:49 PM by emumford. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 05-24-2009, 9:43 PM

    • davidpb
    • Not Ranked
    • Joined on 05-25-2009, 1:38 AM
    • Posts 1

    Dynamically Generate Rewrite Maps?

    Hi,

    Is it possible to dynamically generate rewrite maps?  I have hundreds of products in my product catalogue so it isn't feasible to add a key/value pair for each possibility.

     e.g. www.somedomain.com/products.aspx?id=1 should rewrite to www.somedomain.com/products/fitness

    Or is there a better way of handling this?

     

    Thanks,

    David.

  • 05-27-2009, 7:49 PM In reply to

    Re: Dynamically Generate Rewrite Maps?

    If you're using SQL Server 2005/2008, here's a trick I have have used...  It will generate an XML node set that you can copy and paste directly into your web.config or linked rewrite map file

    DECLARE @rewriteMapValues TABLE ([name] NVARCHAR(100), [key] NVARCHAR(256), [value] NVARCHAR(256))

    INSERT INTO @rewriteMapValues SELECT 'Some-UrlRewrite-MapName' [name], [Col1] [key], [Col2] [value] FROM Some.TableName [add] -- Add as many variations of this statement, as you need for maps... I usually have an ID to Name, and Name to ID map pair for translation from a rewrite, or to a redirect

    DECLARE @rewriteMaps TABLE ([name] NVARCHAR(100))

    INSERT INTO @rewriteMaps SELECT DISTINCT [name] FROM @rewriteMapValues

    SELECT [name], (SELECT DISTINCT [key], [value] FROM @rewriteMapValues AS [add] WHERE [name] = [rewriteMap].[name] ORDER BY [key] FOR XML AUTO, TYPE) FROM @rewriteMaps AS [rewriteMap] FOR XML AUTO, TYPE, ROOT('rewriteMaps')

Page 1 of 1 (2 items)
Microsoft Communities