function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Benjamin KesnerBenjamin Kesner 

URL Rewriter and absolute URLs

All the documentation talk about relative urls as does almost all of the examples.  Do anyone know how to use the Site.UrlRewriter to go to an absolute.  For example:

return new PageReference('http://my.example.com/example?pid=' + pid');

no problem doing it relative

return new PageReference(  "/example" + '?pid=' + pid);

Any ideas?  Is it even possible?   On another thread I notice that it does not like the ":" character.  Any way around that?  
Blake TanonBlake Tanon
I'm not sure what you're asking, but this should work?

PageReference( '/example?pid=' + pid);
Benjamin KesnerBenjamin Kesner
It does work, but it changes the URL from our friendly URL to force.com (Which violates our requirements).  So that is the root of our question.

In the larger context, is it possible to rewrite to an absolute at all?  I can see times when we might want to use it and I want to know if it possible.  
Blake TanonBlake Tanon
you could create your own class/method for this, you can't overwrite the root url in a partial pageReference.

call outPageRef pr = new ourPageRef('/test.html');

public class ourPageRef{

    public string ourRoot(string s){
        return 'www.example.com'+s;
    

}
Benjamin KesnerBenjamin Kesner
Ok. And how do I get to the page from a  URL writer class.  How do I get the page to load "www.example.com/test.html"