You need to sign in to do that
Don't have an account?
How to control behavior of Sites "Unauthorized" page
Hello all:
So here' s my situation. I have a custom site, with custom look and feel. It's fully authenticated, such that a user must log in in order to see any pages, as described here:
Ideally, if a user tries to access a restricted page when not logged in, they'll be redirected to my customized login page. But that's not what happens. They are instead sent to the Unauthorized page, which has standard Force.com Sites look and feel.
So, first I tried to reset what the site's "unauthorized" page is. But unlike the site template, active home page or inactive home page, there seems to be no way to reset what the "unauthorized" page is.
So instead I tried to make the Unauthorized page automatically redirect to my login page -- I created a custom controller, added it to the Unauthorized page, and set an action attribute on the page to call a controller method that would cause a redirect, by returning a PageReference to my custom login page. No dice: instead, I mysteriously get the "Under Construction" page when I do this. When I look at the HTTP traffic I don't see any redirect, all I see is a 503 Service Unavailable.
I suppose I could restyle the Unauthorized page to look like my custom login page. But why should I have to?
I'm really not sure where to start. Questions:
- What governs which page counts as the "unauthorized" page for a site? Is the page Id? The page name?
- How do I force the Unauthorized page to simply and always redirect to my login page?
All Answers
Steve,
You should be able to brand the unauthorized page. If you are seeing the force.com branded page even though you are using your own custom branded page, that means an error is happening at runtime when system is trying to display your custom page, failing, and showing the default page.
On the second part, you can't use redirects on these pages in order to avoid infinite redirects between pages, that's why you are seeing this behavior (documented in the online help).
On the site detail page, scroll down to the "Error Pages" section. That is where you customize what error pages are shown to users.
See the screenshot below: