且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从服务器根目录到Apache根目录重定向

更新时间:2021-12-08 00:22:26

执行opendir需要一个实际的路径不是Web服务器的文档根目录的路径。因此,执行opendir(/)正常工作,向您展示了服务器的根目录。

opendir takes an actual path not the path of the web server's document root. Thus, opendir("/") is working correctly to show you the server's root directory.

正如普京所说,而用

opendir($_SERVER["DOCUMENT_ROOT"]);

或可能是更好的安全性。

or probably better for security

opendir(filter_var($_SERVER["DOCUMENT_ROOT"], FILTER_INPUT_STRING));