Search code examples
phphttp-redirectacl

PHP Page Access Control


I use simple access control to allow or restrict users to pages with in a site running on our LAN.

Each page has an unique UID, and the user can only access that page if the UID is in their access control list. This works well.

Users can access the required pages, pages they are not allowed access to are hidden and if they try to go to a 'hidden' page by entering the url then they are redirect back to the home page.

Currently when they log in or if logged in click on the hyper link ('/local/users') they are taken to the default page within /local/users/

The default page is defined in the the .htaccess file and is called home.php Again this is all working well.

What I'd like to do now is allow users access to a new simple home page. Within their ACL I can add a new value ('base'). If this value is set then I can redirect to the user from home.php to base.php

The issue I have is once this value is set, users can only go to base.php as home.php would detect the base value and redirect them to base.php

I'm trying to work out if it's possible when base is set that home.php redirects to base.php BUT have some way they they can also access home.php

I'm thinking..

If they login or goto a href='/users/local' and base is set then home.php will redirect to base.php

if they click on a link a href='/users/local/home.php' and base is set they are allowed access to home.php

if they are in home.php and base is set, if they refresh they stay within home.php

Is any of this possible ?

Thanks


Solution

  • The simplest way I can think of:

    /users/local/ Landing page is set to index.php

    index.php checks if it can send the user to /users/local/base.php if not, send the user to /users/local/home.php instead.

    Since home.php does not do any redirect, this can be accessed by anyone who types the URL, or follow a direct link to it.