+ Start a Discussion
krishnagkrishnag 

URL rewriter class in apex

Hi can anybody help me how to write a URL rewriter class for my site in apex.

Best Answer chosen by Admin (Salesforce Developers) 
RyanGuestRyanGuest

 

global class ARewriter implements Site.UrlRewriter {
   
    global PageReference mapRequestUrl(PageReference myOriginalUrl){
        return myOriginalUrl;
    }
    global List<PageReference> generateUrlFor(List<PageReference> myOriginalUrls){
             return myOriginalUrls;
    }
}

 

This is a super simple example you can start from. It does nothing but return the original URL passed in. You can start from here and slowly change mapRequestUrl function to get going.

 

 

Also check out this blog:

 

http://blog.sforce.com/sforce/2010/05/url-rewriting-for-your-customizing-your-site-urls.html

 

All Answers

RyanGuestRyanGuest

 

global class ARewriter implements Site.UrlRewriter {
   
    global PageReference mapRequestUrl(PageReference myOriginalUrl){
        return myOriginalUrl;
    }
    global List<PageReference> generateUrlFor(List<PageReference> myOriginalUrls){
             return myOriginalUrls;
    }
}

 

This is a super simple example you can start from. It does nothing but return the original URL passed in. You can start from here and slowly change mapRequestUrl function to get going.

 

 

Also check out this blog:

 

http://blog.sforce.com/sforce/2010/05/url-rewriting-for-your-customizing-your-site-urls.html

 

This was selected as the best answer
krishnagkrishnag

thanks ryan i was working on it