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

Possible to use URL ReWriter to redirect to another page?

I'm trying to see if the URL ReWriter functionality can be used to dynamically redirect to another site. The use case is that I'd like to migrate references to older content on another platform over to hitting a part of a site. My plan was to CNAME a rewriter-based site with the old server's domain name, and then have this rewriter site dynamically place the user on a part of another site.

I wrote a URL ReWriter class, and I'm assuming it's the mapping method that is doing all the work in this scenario. My debug code shows that the proper page reference is being set up and returned by the mapper method. When I visit the site (sandbox currently), I'm taken to whatever page is configured as the 401 Unauthorized page, even though I'm not referencing any platform data whatsoever (this is pure Apex logic). I've tried allowing the URL ReWriter class in Public Access Settings. The debug log doesn't even show any messaging related to why the unauthorized page is being shown.

It looks like everything but the actual redirect/URL rewrite is happening as written, but I have nowhere to go at this point. Any insight is appreciated.
Adding on, I want to rewrite a url like to be

I think I've found two issues though. 1, Sites doesn't support ":" as a character in the URL (lame, this is RFC compliant), and 2, Sites doesn't support rewriting to a non-relative URL. The documenation only comments on the fact that URL's are relative when calling PageReference.getURL() on PageReferences, not when building URLs.

Would love some feedback here, but I'm losing hope of being able to do this on the platform. Not looking forward to continuing to operate old servers when I could have gone no-software...:(
OK, so none of this is possible. Because my source URL contains ":", Sites basically fails the whole concept because it doesn't support any page request that doesn't meet the stricter standards for naming a Visualforce page. The URL Rewriter class can never pick up the request. Also, the standard URL Redirects feature can't evaluate these requests either. Looks like Sites isn't ready for this kind of coolness.

I sure hope that the Product Management team for Sites is paying attention to these incredibly insightful and useful questions from Paul...

Amey PriolkarAmey Priolkar
Any updates on it? I'm trying to work on the same i.e. redirecting to another page using URLRewriter. I hve configured everything, getting expected results in debug logs as well, but page is not getting redirected. I tried redirecting to a dummy VF page without any conditions, still was not able to redirect.

Any help is appreciated. Thanks.