简体   繁体   中英

Allow access to specific Codeigniter controller using .htaccess

I am running an 'intranet' online using codeigniter as a framework and have Denied all except one IP from accessing the directory in my .htaccess file.

I want to open just ONE directory / controller to the world

My current .htaccess file is this

Order Deny,Allow
Deny from all
Allow from xxx.xxx.xx.xx

Ideally, I want to allow public to access the www.website.com/FOLDER/ directory only.

I'm certain this is fairly simple, but Codeigniter works on controllers NOT subdirectories.

Hoping you can help

You can check the IP address in the constructor of your controller so that the world cant access the controllers which you do not want to be public. :)

Rough code:

$var=get ip address
if($var!= [ip address here])
{
redirect( [to someother page] );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM