Password protect a folder in CI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Password protect a folder in CI (/showthread.php?tid=1167) |
Password protect a folder in CI - Johnny Stec - 02-16-2015 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! RE: Password protect a folder in CI - Avenirer - 02-17-2015 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... RE: Password protect a folder in CI - Johnny Stec - 02-18-2015 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] </IfModule> RE: Password protect a folder in CI - CroNiX - 02-18-2015 Show the dir structure of public_html and tell us which directory it is you're trying to protect. Is it something like this? -/public_html --/application (CI) --/dir-to-protect --index.php (CI's index) RE: Password protect a folder in CI - Johnny Stec - 02-18-2015 Hi, i've kept application and system folders out of public_html to be safer. As you guessed this is what i got: -/public_html --/img --/css --/js --/dir-to-protect/file-to-protect.php --index.php (CI's index) --and of course .htaccess robots.txt sitemap.xml etc.. ( to let you know i'm a good boy Thanks RE: Password protect a folder in CI - CroNiX - 02-18-2015 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. RE: Password protect a folder in CI - Johnny Stec - 02-19-2015 Hi, as soon as i password protect a directory in my public_html folder, a .htaccess is auto generated inside the directoy eg: -/public_html --/dir_to_protect --/dir_to_protect/.htaccess 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 |