Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Restrict admin access to defined IP addresses

admin

Started by Alan Coggins 5 years ago · 0 replies · 816 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 jeremycherfas, 1 week ago
4 181 2 days ago
General · by lynbor, 6 days ago
2 122 3 days ago
General · by Old Man Umby, 1 week ago
1 100 1 week ago
General · by Sebastian, 1 week ago
1 124 1 week ago
General · by Andy Miller, 3 weeks ago
0 248 3 weeks ago