Whitelist only certain ip addresses

I would like to know if it is possible, to block all IPs, and only allowed whitelisted IPs, if it is possible, then please tell me how to

If you have an .htaccess file in your “htdocs” folder, put this code in there replacing the IP by the one you want to allow:

<RequireAll>
    Require ip xxx.xxx.xxx.xxx 
</RequireAll>

If you need to allow more than one IP address, separate them using a “space”, like this:

<RequireAll>
    Require ip xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy
</RequireAll>

If you don’t have an .htaccess file in your “htdocs” folder, create one and add that code in the file.

Thank you