Restrict WordPress Page by IP

I have a WordPress website and I want to restrict one of the pages to be accessible only by specific IPs. The page is a template for my WordPress theme. The php file of the template is called alley.php

Here is what I tried in the .htaccess file, placed in the template directory

Read More
<FilesMatch alley.php>
 Order Allow,Deny
 Allow from xxx.xxx.xxx.xxx
 Deny from all
</FilesMatch>

but it’s not working for me.

Thanks in advance!

Related posts

Leave a Reply

2 comments

  1. You almost had it, you had the allow and deny the wrong way around

    <Files alley.php>
        order deny,allow
        deny from all
        allow from xxx.xxx.xxx.xxx
    </Files>