chainsawal Posted August 29, 2016 Share Posted August 29, 2016 I have been using GoDaddy for a hosting company for some time (I know... not the favorite of most people)... Today, I was creating subfolders in my site which means I needed to change my php include links from relative (since all the file referencing them were in the same directory) to absolute links. As I am on a shared server, GoDaddy uses home/youraccount/etc.. which isn't the real file path and when I try to use includes it won't work. I also tried <?php include($_SERVER['DOCUMENT_ROOT'].'/home/etc...'); ?> to no avail as it seems they disable that from their side and since I am on a shared server won't provide that info which I understand. Am I just SOL with GoDaddy or is there some other way to reference absolute links while on a shared server that I am not aware of? I can't imagine there is not a way to do this given their size, but their customer support is worthless as they referred me to "PHP documentation" as if there is a section entitled "GoDaddy: Avoid like the Plague" in it. Sorry just frustrated... any help would be appreciated...as moving my entire hosting platform and 5 websites, SQL databases, etc. isn't on my to-do list this year. Chainsaw... Quote Link to comment https://forums.phpfreaks.com/topic/302037-php-include-and-hosting/ Share on other sites More sharing options...
mac_gyver Posted August 29, 2016 Share Posted August 29, 2016 firstly, you are not dealing with web links. include/require statements deal with files, i.e, paths and names. what does echoing $_SERVER['DOCUMENT_ROOT'] give? If the server is set up correctly, it will give - /home/youraccount/etc.., i.e. the path to your account's document root folder, and note the leading / which refers to the root of the current disk. you would just append the folder to where the included files are at to this value, not append the entire path to your document root folder again. Quote Link to comment https://forums.phpfreaks.com/topic/302037-php-include-and-hosting/#findComment-1536843 Share on other sites More sharing options...
ginerjm Posted August 29, 2016 Share Posted August 29, 2016 My hoster uses a similar structure - "/home/mydomainnameabbrev/php". Note the leading slash. I also can use $_SERVER['DOCUMENT_ROOT'] . '../php' to access my php folder. I can't believe that godaddy is removing access to the DOCUMENT_ROOT element so I'm guessing you simply miscoded it. Quote Link to comment https://forums.phpfreaks.com/topic/302037-php-include-and-hosting/#findComment-1536844 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.