Home Codeigniter : Htaccess/Htpasswd in subfolder of controllers
Reply: 0

Codeigniter : Htaccess/Htpasswd in subfolder of controllers

Marc El Bichon
1#
Marc El Bichon Published in 2018-02-10 12:20:41Z

I try to protect a sub folder in a codeigniter's controllers folder with a simpler htaccess login prompt.

my app structure:

Ubuntu 16.04 LTS, php 7, Codeigniter 3.1.7

var/www/html/application var/www/html/assets var/www/html/system .htaccess index.php

the .htaccess in root folder is:

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

In application/controllers, I've created an admin folder and added an admin controller in it: var/www/html/application/controllers/admin/Admin.php

the .htaccess in admin folder is:

AuthType Basic
AuthName "restricted area"
AuthUserFile /var/www/html/application/controllers/admin/.htpasswd
require valid-user

the .htpassword in admin folder looks like this:

username:XXXXXXXXXXXXXXXXXXXXXXXXXXX

when I navigate to the admin controller:

http://example.com/admin/admin

No login is asked and I get a blank page.

Do you have an idea?

Thank you for your help.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.315481 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO