【问题标题】:I can't use <Files> tag in apache to prevent my file from others' access我不能在 apache 中使用 <Files> 标记来防止我的文件被其他人访问
【发布时间】:2016-05-18 12:09:03
【问题描述】:

我现在正在使用 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

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

【问题讨论】:

标签: php wordpress apache .htaccess


【解决方案1】:

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

add_filter('xmlrpc_enabled', '__return_false');

【讨论】:

  • 是的,谢谢,我发现这有点早。但是为什么 标签不适用于我的 .php 文件。你知道吗?谢谢
  • 你用的是哪个服务器?
  • 你开启重写模式了吗? @weizhengxing 因为在我的网站上它很好用
  • apache ,确定我启用它。现在,我将使用我的虚拟机,尝试找出不同之处。希望对您有所帮助。
  • 简单地说,我在我的虚拟机上的 httpd.conf 中添加了“ Order Deny,Allow Deny from all”,它可以工作。但我仍然不知道我的服务器出了什么问题。
【解决方案2】:

@Parth Chavda

ProxyPass /xmlrpc.php !

把上面的代码放在&lt;Virtual Host *80&gt;tag中你下面的代码前面

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 的帮助。

【讨论】:

  • @Parth Chavda 最后我解决了这个问题。
猜你喜欢
  • 1970-01-01
  • 2023-03-12
  • 2022-01-08
  • 1970-01-01
  • 2021-11-20
  • 2015-06-10
  • 2023-03-24
  • 1970-01-01
  • 2015-10-23
相关资源
最近更新 更多