Forum Moderators: buckworks
I'm setting up a subdomain for testing on smallbusiness.yahoo.com (yahoo's webhosting).
Normally, I like to be able to transfer files from the subdomain for testing to the live area of the site without having to change the files.
On most Apache servers I've worked with, for normal links, I can use absolute urls, like:
/folder/file.html"
That works okay on Yahoo, too.
The problem is with php includes. On most Apache servers, I use:
<?php require($_SERVER["DOCUMENT_ROOT"] . "/anyFolder/fileName.php");?>
This works with the main (live) area of the site but not on the testing subdomain. When I use require() in a file on the subdomain, php looks for the required file in the main area, not in the subdomain.
I'm not sure what to call this, but what Yahoo calls the "real root" (the most basic location in my area of the server) is "/".
The environmental variable: $_SERVER["DOCUMENT_ROOT"] returns "/" for both the live and the testing subdomain.
In a typical Apache installation $_SERVER["DOCUMENT_ROOT"] would return different values. The document_root of the subdomain would be "/subDomain". That's what makes the require() useful: the same statement can be used no matter whether it's in the subdomain or the main area.
So here's the question. Can anyone please tell me how to use require() in Yahoo so it works with the subdomains and the main live area, too?
$header = $_SERVER['DOCUMENT_ROOT'] . "/includes/header.inc"/; --in page:
require($header); Now I see that there is also a variable called the ïnclude_path, which you can set using one of these methods:
include_path = .:/usr/local/lib/php:./include
ini_set("include_path", ".:../:./include:../include"); I'll try those. Thanks.
Yahoo has fixed the problem. I suspect that you have to request this, but they can set the server so that subdomains act like Apache subdomains.
The trick was to send a message (well, okay, a number of messages...) to the php support folks at Yahoo webhosting.
[And, yes, I do appreciate their quick and helpful response.]
After working perfectly for a few days, my subdomain stopped working. Yahoo claims it never worked. Yeah, right.
I've been unable to find any environmental variables that point to the root of whatever domain a file is in (the subdomain's root or the main domain's root). So I stuck a little routine at the top of every page that figures out what that root is and use that value in all my php includes.
It's less elegant, but... knock on wood... it's working again.