Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Restrict admin access to defined IP addresses

admin

Started by Alan Coggins 5 years ago · 0 replies · 863 views
5 years ago

I have a static IP and always like to lock down admin access to my own IP using htaccess. Everyone else gets a 403 page. Took a while to work out how to do this with Grav, so posting here in case others need it as well.

This needs to go after RewriteEngine On in the main htaccess file.

TXT
RewriteCond %{REQUEST_URI} ^/admin  
RewriteCond %{REMOTE_ADDR} !=aa.bb.cc.dd  
RewriteRule ^(.*)$ - [R=403,L]

You can define multiple allowed IP addresses by adding extra lines. And obviously if you have renamed the admin path in the config then use that instead.

Suggested topics

Topic Participants Replies Views Activity
General · by Andy Miller, 1 week ago
0 141 1 week ago
General · by lynbor, 1 month ago
3 457 2 weeks ago
General · by lynbor, 3 weeks ago
7 592 2 weeks ago
General · by Harry, 2 weeks ago
0 179 2 weeks ago
General · by Old Man Umby, 1 month ago
2 320 4 weeks ago