.htaccess files not being used

I have the following folder structure

domain.com (/public_html/)
sub.domain.com (/public_html/sub/)
sub.domain.com/dir1/ (/public_html/sub/dir1/)
sub.domain.com/dir1/dir2/ (/public_html/sub/dir1/dir2/)

if I put the following in my .htaccess file at any of these directories

DirectoryIndex index.php

require valid-user
    Require ip x.x.x.x
It has no effect when loading any files in these directories. What am I missing here?

Apache did follow these rules set, but switching to litespeed has meant that IP restrictions have been ignored
order deny,allow
deny from all
allow from Your-IP
this works absolutely fine so it's something about the require function not working