As the title said, how to use htaccess to allow certain IP to access controller /admin
in Codeigniter?
Thank you!
simply in your controller write-
if (!isset($_SERVER['REMOTE_ADDR']) || $_SERVER['REMOTE_ADDR'] != $your_ip_address)) {
exit();
}
You can do this in the application level but if you really want it in the .htaccess
then:
Options +FollowSymlinks
RewriteEngine on
#url to apply rule to
RewriteCond %{REQUEST_URI} /admin$
#ip to allow access
RewriteCond %{REMOTE_HOST} !^111\.222\.333\.444$
#send to root if ip is not allowed
RewriteRule ^.*$ http://www.example.com [R=301,L]
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.