Jump to content

Recommended Posts

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...

Link to comment
https://forums.phpfreaks.com/topic/302037-php-include-and-hosting/
Share on other sites

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.

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.