In our website, CUG are applied on all page except login and error pages. When a page is accessed, it redirects to the login page and after logging in, it open that page.
The problem is with vanity url. If I apply a vanity url to a secured page and try to access it after login, it is working fine. But without login, it gives 404 page rather than redirecting to login page.
We are using etc/maps for resolving the resource and ACS commons error page handler.
From logs, we found that vanity url is being mapped to correct page, but since the page is protected, anonymous resource resolver is not able to resolve it and acs-commons error handler sets the response code as 404 and serves the 404 page.
What could be the best way to handle the vanity url, if access anonymously, it should redirect to login page and after login, page should open.