James Stoddern
James Stoddern

Reputation: 417

Codeigniter - .HTACCESS to deny by IP to a folder/controller

Inside of my application/controllers folder, I have a sub folder called "cms", where I have my admin tools. I need to restrict access to this folder, and its controllers by IP. I have tried using a .HTACCESS file to do this, as follows (but it doesn't work): This file lives withing /application/controllers/cms/

Order Deny,Allow
Deny from All
Allow from XX.XX.XX.XXX

My .HTACCESS file in the root of the application is as follows:

RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

Does anyone know how I can set these two files up to work correctly and allow me to restrict access to the /cms/ folder and its controllers by IP?

I look forward to hearing from you.

Thanks

James

Upvotes: 0

Views: 1268

Answers (2)

Timmytjc
Timmytjc

Reputation: 258

Try this spark:

http://getsparks.org/packages/ip_restrict/versions/HEAD/show

You can have all your CMS controllers extend the CI_Controller method (MY_) and call the spark within the construct.

Upvotes: 1

mallix
mallix

Reputation: 1429

So this doesn t work ?
Creating an htaccess file inside the cms folder with the following:

order deny, allow
deny from all
allow from xxx.xxx.xxx.xxx

Upvotes: 0

Related Questions