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

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!
Reply
#2

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...
Reply
#3

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>
Reply
#4

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)
Reply
#5

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 Smile

Thanks
Reply
#6

(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.
Reply
#7

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB