Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Custom logout page per site (multi site)


Former Community Member

We have 3 different sites.. SandA, SandB, SandC and each of them have different Login pages. How can i configure/code the "Logout" link on the page?

So if i'm on site: SandA, the href for Logout is defined like this http://localhost:4502/system/sling/logout but this is using the RootMappingServlet and taking all Logout links on all sites to the one i configured. How can i solve this?

There were several posts but they did not discuss on configuring logout urls for multi-sites

2 Replies


Level 10

You can write a custom 'RootMappingServlet' and based on the page where the logout is hit, you can have the logout page configured.


Former Community Member

I'd be interested to learn more on writing a custom RootMappingServlet. Can you send me a brief example? 

I did try to write a custom LogoutServlet, define a custom url instead of using "/system/sling/logout", and used Authenticator.logout(request, response). This method works but the problem is that the Response gets invalidated and we cannot use a custom Redirect url. Whatever is defined in the RootMappingServlet is picked to show. This works good if you have one site. But for multi-site this was not the case.

One solution that worked for me:

We can add "resource" param to "/system/sling/logout" defining the path that should load after logout. No need to write any additional code. 

<a href="https://forums.adobe.com/system/sling/logout?resource=/content/yoursite/en.html">Logout</a>

If you have multiple sites, then.. your Root Mapping Servlet can be the default value (for us it was : /projects.html)

<a href="https://forums.adobe.com/system/sling/logout?resource=/content/yoursite1/en.html">Logout</a> <a href="https://forums.adobe.com/system/sling/logout?resource=/content/yoursite2/en.html">Logout</a>