HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to redirect guests to a custom html page?

I'd like to have a simple html landing page that guests will see instead of the register/login page, with a button that will then direct them to the login page on the forum. What would be the best way to do this?

I have already been using Basic Pages to create new pages within my site, but for this landing page I don't want it to have any of the forum elements on it eg. title bar or headers/footers. Just a page where I will have a button that links to the register page.

I've made the html page with some css. I know a bit of PHP and I'm assuming I'll need to do something with the routes and controllers to make this happen?

Thanks in advance.

PS. I'm using a self-hosted version of Vanilla - Version 2021.009.

Answers

  • Does anyone know anything about this? 🙂 I've tried several things already and nothing seems to work. I have an html landing page saved in the root directory and I'm simply trying to redirect to it when anyone visits the site and is not logged in.

    Things I've tried:

    I installed a plugin called GuestDefaultRoute, which is meant to bring up a settings menu but the menu is blank. I think it might be only for internal routes anyway so it might be a red herring.

    I tried making my own plugin too, and doing a custom redirect that is something like this:

    ?php if (!defined('APPLICATION')) exit();
    
    class CustomLandingPagePlugin extends Gdn_Plugin {
        public function base_beforeControllerMethod_handler($sender) {
            // Check if the user is not logged in and the controller is not Login or Register
    
            if (!$sender->User->UserID && !in_array(strtolower($sender->ControllerName), ['entrycontroller', 'registercontroller'])) {
                // Redirect to the landing page
                $sender->redirect('/landing-page.html');
            }
        }
    }
    

    But that didn't seem to do anything.

    The application already redirects automatically to the signin page when you visit the main url, so if I can just work out where that redirect happens I should be able to tap into that and redirect it to the landing page instead (which then has a link to the signin page).

    Hope someone can help! 😊

  • Were you able to resolve this? I also need to redirect the guests to the login page.

Sign In or Register to comment.