简体   繁体   中英

How to protect files in public folder in codeIgniter?

how can I protect files in the public folder in the CodeIgniter framework to be not viewed by a user who is not logged in? My public folder structure is as follows:

  • public
    • logs
      • detailed_logs(public/logs/detailed_logs)
      • error_logs(public/logs/error_logs)
    • code
      • device.js(public/code/device.js)

I am able to access the files using the below URLs without logging in to the system.

  1. https://<ip_address>/logs/detailed_logs
  2. https://<ip_address>/code/device.js

Can someone help me in making it only accessible to the user who is logged in?

I added the .htaccess file to the logs folder and allowed access only to the index.php file. I also created PHP files for each log file and checked whether a user is logged in using the session variable and read the contents of the respective log files when verified the user is logged in. Thanks for the help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM