Redirect discover page to login page

Hi ! I’m looking for a way to restrict unauthenticated users access by showing them only the /login page. I know that by default, unauthenticated users have access to the /discover page. Therefore, I want to redirect the /discover page to the /login page. I tried doing this by adding the following to the nginx configuration file :

    location /discover {
        return 301 /login;
    }

But it seems that it doesn’t work. When an unauthenticated user visits the URL mytaiga.lan, they are redirected to mytaiga.lan/discover but not to mytaiga.lan/login.

However, when they visit the URL mytaiga.lan/discover instead of mytaiga.lan, they are correctly redirected to mytaiga.lan/login.

Any help would be greatly appreciated. Thank you !

Try adding the following to the nginx config file

    location = / {
        return 301 /login;
    }

and remove any existing location = / block

Cheers!

1 Like