How to prevent access of admin pages by knowing the admin page url?

后端 未结 7 1141
庸人自扰
庸人自扰 2020-12-17 07:52

If someone knows my url of the admin page such as www.example.com/admin.php, then they will easily access the page by directly accesing that url. How to restrict this. Pleas

7条回答
  •  星月不相逢
    2020-12-17 08:03

    You should never make the admin section public. You can't rely on obscurity for this, authorisation is the way to go. You can do this by using .htacces, as described here, or by relying on PHP. A crude example follows below.

    Below is a simple login implementation. If the password is correct it will allow the user to go to admin.php. You should read the PHP manual on sessions though, because the session header should be present on every page behind the login page. The password handling could be handled more secure as well.

    
    
      
        
        My login page
      
      
        




提交回复
热议问题