Question

I know we can easily redirect a path to another path with Redirect module, but what I want to do is more complicated, my condition is when the user has a specified IP and the route is matched with to a specified path redirect it.

Pseudo code what I'm looking for is

if $path='xxxxx' and $user_ip = 'yyy.yyy.yyy.yyy' redirect to 'zzzzz'

how I can implement this, what I need is where is the best place to implement this?

Was it helpful?

Solution

You can alter the routes (conditionally based on IP) by creating an event subscriber or by using a RouteSubscriber. You should also look at altering existing routes.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top