Problem: Using a URL Rewriter class causes failure of a View override page

Background: We have a community portal with a custom Visualforce application. We have overridden the View action on Case with a Visualforce page.

Within our application, we have a Chatter publisher widget where we can @mention portal users. When the user receives the notification email from Salesforce, they can click on the link, login to the portal, and they'll be presented with the record detail within the VF application. We do have a custom login page for this portal.

Current Situation: This was all working fine until we implemented an URL Rewriter class for the community site. Now, we have different problems in production vs sandbox. In production, after the portal user logs in, he sees an error "Error occurred while loading a Visualforce page. Formula Expression is required on the action attributes." In the sandbox, we don't get this error, but instead the app's custom error handling kicks in and throws a generic error page.

If I remove the URL rewriter, then it works fine.

I suspect it has to do with the View override page, which looks like this:

<apex:page standardController="Case" extensions="SettingsExtension"
                     action="{!IF(settings.Deactivate_View_Overrides__c, URLFOR($Action.Case.View, Case.Id, null, true),
                                    URLFOR($Page.ViewClientOverview, null, [id=Case.HC_Id__c, caseId=Case.Id], true))}"
    <apex:outputPanel style="display:none;" >

The URL Rewriter is only checking for a specific inbound URL format -- it is not changing any "output" URLs.

global class HL_UrlRewriter implements Site.UrlRewriter {
    String LIVE_LINK = '/shortener/';
    String redirectBase = '/My_Redirector?url=';
    String redirectUrl;

    global PageReference mapRequestUrl(PageReference original) {
        String theUrl = original.getUrl();
        if (theUrl.startsWith(LIVE_LINK)) {
            return processLiveLink(theUrl);
        return null;

    // This method must exist but we don't use it.
    global List<PageReference> generateUrlFor(List<PageReference> salesforceUrls) {
        return salesforceUrls;

    private PageReference processLiveLink(String theUrl) {
        // the code here does not run during situation described in this post.

According to this blog entry,

Any URL which contains a Salesforce Object ID ... Salesforce’s standard UI will kick in and take control, so if you have a URL like


Salesforce is going to kick in and take that request, sending it to the standard page handler before it gets to your re-writer

However, the Chatter link that I get in the email has several parameters after the ID, like s1oid, s1nid, OpenCommentForEdit, etc.

So I have a few questions:

  1. If there are parameters after the object ID, will Salesforce still take control and skip the URL Rewriter?

  2. If the URL rewriter is indeed being skipped, why is it affecting the override page?

  3. Is there a way to get more information in the debug log to see what's happening in the action parameter of the override page? I've already set Finer on Visualforce but I didn't get any clearer detail from

  • Just an idea that popped into my head while reading your qestion, have you considered something like encrypting the ID in the url so that salesforce doesn't think it's an Id? doing something simple like taking the key prefix and putting it into a different param should be enough something like key=005&id=0000000XXXX I'm not 100% sure if that will work but it's something you can test while you wait for a real answer.
    – gNerb
    Commented May 14, 2018 at 19:33
  • 1
    Thanks, but I don't think that can be done because the email and link are generated by the Salesforce Chatter notification process and can't be modified. I am considering rewriting the override page to use a PageReference action in the controller rather than URLFOR in the page. Commented May 14, 2018 at 20:07
  • If you leave the rewrite class in place but turn off the view override, what happens? Just curious - I wonder if the rewriter class is having some unexpected side effect that's throwing off Visualforce...
    – Benj
    Commented May 18, 2018 at 21:18

1 Answer 1


I fixed this by writing a controller extension with a method to do a page redirect and I got rid of the URLFOR in the VF page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .