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


    Order deny,allow
    Deny from all
    Allow from 103.35.199.82
    Allow from 51.38.246.115

Restart apache

systemctl restart httpd

Or

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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *