Welcome Guest, Not a member yet? Register   Sign In
Password protect a folder
#1

[eluser]Unknown[/eluser]
I have a folder inside my 'views' folder called 'admin' and inside that folder is a .php page. I was wondering how to basically password protect that page so that the user has to login to access it? I tried password protecting the admin folder with .htaccess and .htpasswd but it didn't work for some reason.
#2

[eluser]sarciszewski[/eluser]
Are you using an Apache webserver, or are you running nginx / lighttpd / IIS?
#3

[eluser]CroNiX[/eluser]
You can't protect that dir using htaccess. That only works if you actually visit that dir directly and it appears in the url, which doesn't happen with CI as views are accessed within the controller. You'd need a user auth library or something, and check whether they are logged in or otherwise allowed to view that page via their permissions within the admin controller before allowing them to access the page(s).

You can google "codeigniter user authentication" to find some libraries that have already been created for this purpose.




Theme © iAndrew 2016 - Forum software by © MyBB