How can I block a Specific IP Address from .htaccess?

Hi, The allow-block command for .htaccess does not work in Cyberpanel. That’s why I’m having trouble directing a rope.

What I want to do is exactly this: I just want to redirect visitors from a particular ip to a different domain.

The following code works with redirect, but it applies to everyone. I just want it to work for specific ip addresses. I’ve tried many ways, but I failed.

RewriteEngine on
RewriteRule (. *) Https://newdomain.com/ [R = 301, L]

Thanks in advance for the help.

I suppose you are using free version of CyberPanel which comes with OpenLiteSpeed and OpenLiteSpeed does not have full support of .htaccess directives, kindly visit this guide to block access for certain IPs → .htaccess restrict access to site via IP address | OpenLiteSpeed Community and News