UrlRedirect from Internal to Internal

Vote:
 

I hvae read the article Create a custom url rewrite provider, which has provided me with a good insite into how the provider works, and am now trying to modify to my requirements.

I am working with a menu and products with the following structure.

-- Menu
---- Category
---- Category 2
-- Products
---- Product 1
---- Product 2

I've been able to rewrite the outgoing links for products, i.e. /Products/Product1/ to /Menu/Product1, but I'm trying to map the /Menu/Product1/ to /Products/Product1.

In the example, it is assuming the url segment of the product(user) name, is not an actual page, whereas in my case, it is. Instead of loading a ProductDetailPage reference and setting an id, is there a simpler way?

#49549
Mar 23, 2011 7:36
Vote:
 

What I've also tried to do, is in the ConvertToInternalInternal method, call:

                base.ConvertToInternal(new UrlBuilder(url.Uri.AbsoluteUri.Replace("/Menu/", "/Products/")), out internalObject);

url.Path = url.Path.Replace("/Menu/", "/Products/");
however it doesn't seem to resolve to the correct internal page or url, even though the base.ConvertToInternal is finding the correct product internal object.
#49550
Mar 23, 2011 7:47
Vote:
 

This works for me:

 

protected override bool ConvertToInternalInternal(EPiServer.UrlBuilder url, ref object internalObject)
        {
            if (url != null && (url.Path.ToLower().Contains("/test/")))
            {
                url.Path = url.Path.Replace("test", "articles");
            }

            return base.ConvertToInternalInternal(url, ref internalObject);
        }

#49554
Mar 23, 2011 12:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.