Php 通过IP限制Wordpress页面

Php 通过IP限制Wordpress页面,php,wordpress,.htaccess,Php,Wordpress,.htaccess,我有一个WordPress网站,我想限制其中一个页面只能由特定的IP访问。该页面是我的WordPress主题的模板。模板的php文件名为alley.php 下面是我在模板目录下的.htaccess文件中尝试的内容 <FilesMatch alley.php> Order Allow,Deny Allow from xxx.xxx.xxx.xxx Deny from all </FilesMatch> 命令允许,拒绝 允许从xxx.xxx.xxx.xxx开始 全盘

我有一个WordPress网站,我想限制其中一个页面只能由特定的IP访问。该页面是我的WordPress主题的模板。模板的php文件名为alley.php

下面是我在模板目录下的.htaccess文件中尝试的内容

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

命令允许,拒绝
允许从xxx.xxx.xxx.xxx开始
全盘否定
但这对我不起作用


提前谢谢

你差一点就成功了,你的允许和拒绝方式都不对

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

命令拒绝,允许
全盘否定
允许从xxx.xxx.xxx.xxx开始

我认为这个插件会对你有所帮助


你好,Howlin,谢谢你的回复,但我仍然可以从所有IP访问该页面。你能对页面进行硬刷新以再次检查吗?此外,htaccess需要与alley.php文件.sudo/etc/init.d/apache(2?)restart位于同一目录中