Restrict Location Match by IP via .htaccess

.htaccessapache-2.2litespeed

I have a url path defined in rewrite rules ('/admin') which I would like to restrict access to only 1 ip address. I'd image the best way would to use .htaccess rather than coding it in. I've tried this but it didn't work. It blocked all urls, not just urls with /admin.

<Location /admin>
    Deny from all
    Allow from x.x.x.x
</Location>

Best Answer

Location directive is not allowed in .htaccess file. Otherwise, you can add these lines in your Apache configuration file / virtual host file.