我无法在apache中使用<files>标记来阻止我的文件来自其他人。访问

时间:2016-05-18 12:09:03

标签: php wordpress apache .htaccess

我现在正在使用wordpress。今天我发现我的xmlrpc.php文件已启用。现在,我要禁用它。但我在下面做的工作

<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
</Files>

实际上,所有* .php文件都不会以这种方式工作。但是,如果文件不以.php结尾,则可以正常工作

<Files "test.txt">
    Order Deny,Allow
    Deny from all
</Files>

这是我的.htaccess文件,我也尝试在httpd.conf中编写它,结果相同

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
<Files xmlrpc.php>
    Order Deny,Allow
    Deny from all
</Files>
<Files "php_test.php">
    Order Deny,Allow
    Deny from all
</Files>
<Files "test.txt">
    Order Deny,Allow
    Deny from all
</Files>

test.txt

当我在服务器中访问test.txt时,我得到了这个。 但是php_test.php我得到了这张照片

php_test.php

我已经尝试了很多方法来解决这个问题,现在我需要帮助,谢谢你们

2 个答案:

答案 0 :(得分:0)

我在网站相关插件的代码下面有替代解决方案。

add_filter('xmlrpc_enabled', '__return_false');

答案 1 :(得分:0)

@Parth Chavda

ProxyPass /xmlrpc.php !

将上面的代码放在<Virtual Host *80>标记

下面代码的前面
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:10000/yjdata/www/wordpress/$1

尝试访问http://www.yourdomin.com/xmlrpc.php,你得到这个!!!!

Forbidden

You don't have permission to access /xmlrpc.php on this server

此问题得到解决。感谢Parth Chavda的帮助。