How to redirect to different lading pages for anonymous users in Drupal 8

I have a site that has several resources protected from anonymous users. Right now I have the anonymous users module installed and each of those pages redirects to the login page and the user can register or login and then is successfully redirected to the resource they tried to visit. What I want to implement builds off of this, but is not possible with this module.

I would like when a visitor attempts to access a specific page, then they get redirected to a specific landing page with a login form.

In wordpress I would just have php logic at the top of each of my protected pages and then redirect to the appropriate landing page, but I am struggling with how to do this in drupal.

The basic logic I need is check if !user_logged_in && page_path == x, redirect to pageY. etc…

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *