UrlRewriter Interface

Enables rewriting Sites URLs.

Namespace

Site

Usage

Sites provides built-in logic that helps you display user-friendly URLs and links to site visitors. Create rules to rewrite URL requests typed into the address bar, launched from bookmarks, or linked from external websites. You can also create rules to rewrite the URLs for links within site pages. URL rewriting not only makes URLs more descriptive and intuitive for users, it allows search engines to better index your site pages.

For example, let's say that you have a blog site. Without URL rewriting, a blog entry's URL might look like this: http://myblog.force.com/posts?id=003D000000Q0PcN

To rewrite URLs for a site, create an Apex class that maps the original URLs to user-friendly URLs, and then add the Apex class to your site.

UrlRewriter Methods

The following are methods for UrlRewriter. All are instance methods.

generateUrlFor(salesforceUrls)

Maps a list of Salesforce URLs to a list of user-friendly URLs.

Signature

public System.PageReference[] generateUrlFor(System.PageReference[] salesforceUrls)

Parameters

salesforceUrls
Type: System.PageReference[]

Return Value

Type: System.PageReference[]

Usage

You can use List<PageReference> instead of PageReference[], if you prefer.

Important

Important

The size and order of the input list of Salesforce URLs must exactly correspond to the size and order of the generated list of user-friendly URLs. The generateUrlFor method maps input URLs to output URLs based on the order in the lists.

mapRequestUrl(userFriendlyUrl)

Maps a user-friendly URL to a Salesforce URL.

Signature

public System.PageReference mapRequestUrl(System.PageReference userFriendlyUrl)

Parameters

userFriendlyUrl
Type: System.PageReference

Return Value

Type: System.PageReference