Not authorized on statis side

I created a static site for showing some general information stuff.
Page is in folder /templates/pages/general.php
In my pagescontroller I added the beforeFiler function and added there the line for UnauthenticatdActions.

public function beforeFilter(\Cake\Event\EventInterface $event)
    {
        parent::beforeFilter($event);
        // Configure the login action to not require authentication, preventing
        // the infinite redirect loop issue

        $this->Authentication->addUnauthenticatedActions(['general']);
    }

But still I cannot show the page.
What is wrong? Do static sites behave different?

What does “cannot show the page” mean? What URL are you trying to access? What route do you have set up that would enable this? Do you get an error message or a blank page? Have you enabled debugging?

Hi, I try to open page like this.

I thought it is some standard functionality, but I am not sure.

So, “cannot show the page” means it redirects to a login? You have still not indicated what route you have set up that you expect to apply to this page.

Sorry, missed this detail.
Here is URL I want to open
http://www.myprivatepage.com/pages/general

Maybe your routes.php file has something which redirects it. Show us your file.
If not, this code works for me (cake 4) and does not require authentication.

    // In UsersController.php
    public function beforeFilter(EventInterface $event)
    {
        parent::beforeFilter($event);
        // Allow login and add
        $this->Authentication->addUnauthenticatedActions([ 'lion']);
    }

    public function lion()
    {
        // Add contents or return json output for testing
        $this->RequestHandler->renderAs($this, 'json');
        $this->response->withType('application/json');
        $this->viewBuilder()->setOption('serialize', true);
    }

@efjot The addUnauthenticatedActions() method takes action names as arguments. Your /templates/pages/general.php is served by the PagesController::display() method, so the action name you need to use is display, not general.

Do keep in mind that this means every template under /templates/pages/ will be accessible without authentication. So you should create another action to serve protected pages (and setup route accordingly).

Also casing is important. It should probably be /templates/Pages/… As thats the controller name.

Thanks a lot. It was “display” what should be added and not “general”.
Thanks @ADmad