Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Restrict admin access to defined IP addresses

admin

Started by Alan Coggins 5 years ago · 0 replies · 1007 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 themetman, 23 hours ago
2 40 16 hours ago
General · by Hanns Mattes, 1 week ago
0 121 1 week ago
General · by Karmalakas, 1 week ago
2 185 1 week ago
General · by Hanns Mattes, 3 weeks ago
0 235 3 weeks ago
General · by Dima, 4 weeks ago
1 211 4 weeks ago