php - 在 GET 变量中传递 URL 时禁止访问 403

标签 php apache .htaccess

我遇到这样的问题:
403 Forbidden on PHP page called with url encoded in a $_GET parameter

我收到“403 禁止”错误 当我像这样将 url 作为 GET 变量传递时

http://script/test.php?url=https://stackoverflow.com/questions/ask

但这没关系。

http://script/test.php?url=stackoverflow.com/questions/ask

即使我对 url 进行 urlencode,它仍然会给我一个 403。

Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at ----- Port 80

而且我认为该服务器没有启用 mod_security,因为当我在 htaccess 中添加 SecFilterEngine Off 时,我得到“500 Internal Server Error”。

代码片段:

$URL = mysql_real_escape_string($_GET['url']);
mysql_query("INSERT INTO `url` ...");

所以问题是,我是否可以在不编辑 httpd.conf 的情况下解决这个问题,因为我没有 root 权限。 谢谢

最佳答案

您是否有权访问 apache 错误日志本身?如果这是一个 cPanel 系统并且您有 shell 访问权限,请尝试查看日志/usr/local/apache/logs/error_log - mod_security 错误将出现在那里。否则,您可以查看控制面板内部,看它是否发现任何错误消息。

即使安装了 mod_security,如果不允许使用关键字,将 SecFilterEngine 放入 .htaccess 后仍然会出现 500 错误。

我建议联系您的虚拟主机以确定是否是 mod_security 的原因。如果是,您可以要求他们创建一个异常(exception)。 (我在一家网络托管公司工作,我们几乎总是乐于为合理的应用程序设置 mod_security 异常(exception))

如果它是由 mod_security 引起的并且您的虚拟主机不会创建异常,则您需要更改托管公司或找到其他方式来传递 url(base64 编码可能适合您)

关于php - 在 GET 变量中传递 URL 时禁止访问 403,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6354133/

相关文章:

.htaccess 非 www 到无 www SSL 和 www 到 www SSL

javascript - (未知网址)Angular 4 的 Http 失败响应

php - 如何将模型数据对象数组转换为dataProvider

macos - MAMP 专业版 : Apache couldn't be started because the port was already in use

apache - java.io.NotSerializableException : org. apache.camel.component.file.GenericFile

.htaccess:此处不允许使用 RewriteEngine

php - 模拟测试对象的公共(public)方法

php - Eloquent - 使用字符串值而不是列标题连接子句

.htaccess - Angular 2在刷新时找不到路线

php - X-UA-与 HTTP header 的兼容性