Apache Limit access to a url
I want to limit access to admin login url of a web application to specified IP address.
The web site had admin login in following URL
https://domain.com/login
To limit IP address, i edited Apache VirtualHost configuration for this web site, added
1 2 3 4 5 6 |
<Location /login> Order deny,allow Deny from all Allow from 103.35.199.82 Allow from 51.38.246.115 </Location> |
Restart apache
1 |
systemctl restart httpd |
Or
1 |
systemctl restart apache2 |
Now only IP listed on the Allow from directive are allowed to access the /login URL.
NOTE: this won’t work in .htaccess file. You need to add it in Apache VirtualHost.