PHP - Document_Root 与子域
我的配置文件中有以下代码来建立根路径,然后在整个应用程序中使用该根路径:
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'].'/MyAppFolder/');
问题是它似乎不适用于子域。如果我尝试将配置文件包含到子域上的 PHP 文件中,自然会收到错误。
我该如何解决这个问题?如何建立允许子域的根路径?我以前从未这样做过,所以我不知道如何去做。
谢谢你!
I have the following code in my configuration file to establish the root path which is then used throughout the application:
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'].'/MyAppFolder/');
The problem is that it does not seem to work with sub domains. if I try to include my configuration file into a PHP file that is on the sub domain, naturally, I get an error.
How can I get around this problem? How can I establish a root path that allows sub domains? I've never done this before so I haven't a clue how to go about it.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在引导文件中执行某些操作:
这显然取决于要运行的第一个文件是否位于子目录中。
例如
,附注,这实际上是一种正确访问应用程序文件的方法,而不一定确定您是否位于 Web 服务器的文档根目录中。无论如何希望这会有所帮助,或者至少给你一些想法。
You could do something in your bootstrap file:
This obviously depends on if the first file to run is in a subdirectory or not.
e.g.
A side note, this is really meant as a way to correctly access your applications files and not necessarily determine if you are in the document root of your web server. Anyway hope this helps, or at least gives you some ideas.