PHP fopen returns 403 禁止使用 HTTPS

PHP fopen returns 403 Forbidden with HTTPS

我在 Linux、Apache 和 php 5.2.17 的托管站点上 allow_url_fopen=true,php 页面检查图像是否存在with fopen (fopen($_SESSION['IMG_DIR_REL']."/img/img5.jpg", "rb")); 我不使用 file_exists 因为它 returns "nothing" :-( 。 该页面位于子目录 ./test/ 中,图像位于子目录中 ./img/ 如果我使用 http (http://www.example.com/test/control.php) 访问该页面,fopen 可以完美地提供正确的图像。 但是,如果我使用 https (https://www.example.com/test/control.php) I got the fopen(https://www.example.com/img/img5.jpg) [function.fopen] 访问同一页面:无法打开流:HTTP 请求失败! HTTP/1.1 403 禁止。 如果我改为 fopen (fopen("../img/img5.jpg", "rb"));它适用于 https。 我在谷歌上搜索了一下,测试了一些类似案例的例子,但没有任何效果。 你有什么建议吗? 提前致谢。

这很可能意味着 Apache 无法访问“/img/img5.jpg”。

如果是这种情况,您需要更改文件的权限或所有权。

确保文件的所有者是 运行 服务器组的一部分。

默认情况下,Apache 在 httpd 组上运行。