Welcome Guest, Not a member yet? Register   Sign In
Password protect a folder in CI

Hi, i'm struggling coz i'd need to password protect a folder inside public_html on my server, it's to allow the customer to access stats from the browser without giving access to cpanel.
But CI installation keeps on giving a 404 all the time i try to access the folder after i password protect it via htaccess.
Any suggestion.
Thanks a lot in advance!

Are you sure is a folder and not a CI controller? If the answer is yes, show me your .htaccess that can be found in your public_html directory. If the answer is no, then you can't password protect a controller with .htaccess...

Hi, for sure i'm talking about a folder.
My .htaccess looks like this..

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteCond %{HTTP_HOST} ^mysite\.com
   RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteRule ^(.*)$ index.php?/$1 [L]


Show the dir structure of public_html and tell us which directory it is you're trying to protect.

Is it something like this?
--/application (CI)
--index.php (CI's index)

Hi, i've kept application and system folders out of public_html to be safer.
As you guessed this is what i got:
--index.php (CI's index)
--and of course .htaccess robots.txt sitemap.xml etc.. ( to let you know i'm a good boy Smile


(This post was last modified: 02-18-2015, 12:22 PM by CroNiX.)

did you create an htaccess file with the http auth directives IN your /dir-to-protect dir? Not within the .htaccess of your public_html dir (for CI), but in the dir you want to protect itself.

as soon as i password protect a directory in my public_html folder,
a .htaccess is auto generated inside the directoy eg:
This is what inside the file:
AuthType Basic
AuthName "folder_to_protect"
AuthUserFile "/home/user/.htpasswds/public_html/folder_to_protect/passwd"
require valid-user

Theme © iAndrew 2016 - Forum software by © MyBB