Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
UrlBuilder url = new UrlBuilder(page.LinkURL);
EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, page.PageLink, System.Text.UTF8Encoding.UTF8);
// url now contains the rewritten URL
Note that the second parameter (page.PageLink) is not necessary, passing null will deduce the PageReference from the url, but if it is known you will gain some perf by passing it.
You should also take a look at the GetHtmlRewriter method on UrlRewriteProvider. This will rewrite an entire HTML chunk with friendly url conversion and rebasing, which may be closer to what you need.
Best Regards, Magnus Stråle