Search code examples
codeigniter.htpasswd

Protect Codeigniter application during development


How can I protect my webapp build with Codeigniter with a htpasswd during development? I tried this but I get 500 error.

AuthType Basic
AuthName "Authenticate please"
AuthUserFile /usr/html/.htpasswd
Require valid-user

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|files|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Solution

  • Your auth looks ok to me I have below that works fine. Are you sure you've created your .htpasswd file correctly and it lives at the location you specified?

    <Files *>
    AuthName "Please Login"
    AuthType Basic
    AuthUserFile /var/www/.htpasswd
    require valid-user
    </Files>
    

    I would say something is wrong with your rewrite cond and rules. Any reason you are not using the one here -> http://codeigniter.com/wiki/mod_rewrite