SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_SERVER['DOCUMENT_ROOT'] problem

    HI,
    on my shared hosting, when i tried it, it does return a path, but that part is kind of fixed, it doesn't actually represent the ROOT path. like its fixed

    I am on Linux, with Apache

    What you think i can suggest or do to fix it?
    is there any alternative for $_SERVER['DOCUMENT_ROOT'] in case nothing works?

    why do you think its like?
    is it made fixed in Apache?


    thanks
    ---------------------------
    Errors = Improved Programming.
    My Site

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    dcument root

    The document root is "where your web site is".

    On a shared host the document root should look like this
    /home/domainna/public_html
    Note* only the first 8 letters of the domain name are used

    Does your document root not look like this?
    Or are you looking for something else?

  3. #3
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, its not like this, like i said its like somebody made it to be fixed
    its always at /usr/local/apace/htdocs

    i dont know why? how can it be fixed? or is there any alternative?

    thanks
    ---------------------------
    Errors = Improved Programming.
    My Site

  4. #4
    SitePoint Evangelist Will Kelly's Avatar
    Join Date
    May 2005
    Location
    London
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $_SERVER['DOCUMENT_ROOT'] only shows the path to base folder of your site, not any sub-dirs etc.

    $_SERVER["SCRIPT_FILENAME"] shows everything up to and including the current file.

  5. #5
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, but the my base path is
    /home/vhosts/wwwweb

    not
    /usr/local/apache/htdocs
    ---------------------------
    Errors = Improved Programming.
    My Site

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    Server document root /usr/local/apache/htdocs

    I did a search for "usr/local/apache/htdocs". Most of the results were error, warning, and notice pages (you are not alone). My first thought was a security attack, but I did notice a WebDEV page dealing with proper configuration settings. I can somewhat accept the possibility of the root being in apache, but in the documentation? Unless this is just a path setting issue that you can resolve, I think you should notify your host server. Sorry I can't be more helpful, hopefully someone more knowledgeable will respond to this thread.

  7. #7
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, you mean it might be some cinfguration in Apache??
    ---------------------------
    Errors = Improved Programming.
    My Site

  8. #8
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems your hoster forgot to configure document_root for virtual hosts.

  9. #9
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah i see, thanks now i can tell him in words, what seems to be the problem,


    thanks

    will post back whether the problem is solved or not for others
    ---------------------------
    Errors = Improved Programming.
    My Site

  10. #10
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can this be changed with .htaccess?

    if yes, can you give any example?
    ---------------------------
    Errors = Improved Programming.
    My Site

  11. #11
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    document root

    I believe that the value is set in the httpd.conf file, not htaccess. Your host should take care of it for you. (and hopefully soon)

  12. #12
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, what you think i should ask my host to do exactly.
    should i say what stereofrog said?
    Quote Originally Posted by stereofrog
    Seems your hoster forgot to configure document_root for virtual hosts.
    ---------------------------
    Errors = Improved Programming.
    My Site

  13. #13
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,156
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    contacting host

    Yes, try not to come across hot, but explain the situation to them. I would tell them what the PHP scripts are giving as the document root and that you suspect there may be a virtual host configuration problem with the httpd.conf file. They should want to resolve this for their own benefit (I wouldn't want to p-o my customers) and will hopefully be able to fix it soon. (Or suggest an alternative explanation if that is the case.)

  14. #14
    SitePoint Enthusiast
    Join Date
    Jul 2003
    Location
    NJ
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All,

    I noticed that if I use my full domain name (i.e. http://www.mydomain.com) on my shared host, that the $_SERVER['DOCUMENT_ROOT'] variable points to the correct path, /home/mydomain/public_html. However, if I use the real IP address with the account name (i.e. http://99.99.99.99/~mydomain), the $_SERVER['DOCUMENT_ROOT'] variable points to that /apache/doc folder that was discussed above.

    I know it's a shared host on a shared IP address, but shouldn't that ~account_name qualify it enough so that the server can map the document root for my site? The reason I ask is that when I move my site to a different server for production, I want to keep my shared host as a development site. So when I switch the DNS, I'll have to use the IP/account_name syntax. Now I can't do that because it screws up all my includes.

    Any thoughts?

    J.

  15. #15
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had that problem on a server of one of my clients. And they said it happens in those accounts with IP/~ and there was nothing they could do.

    They said the $_SERVER['DOCUMENT_ROOT'] is for that IP not for that account, since in this case it acts like a sub directory to that IP. So, you have to live with that.

    Thats what they told me. Maybe there is a solution which any server admin can provide.


    It was temporary as they were moving that account. So, for the time being the solution i came up with was.
    In my config file, which was being loaded before any other file i did this
    PHP Code:
    $_SERVER['DOCUMENT_ROOT']) =     str_replace((str_replace('/~mydomain','',$_SERVER['PHP_SELF'])),'',$_SERVER['PATH_TRANSLATED']); 
    ---------------------------
    Errors = Improved Programming.
    My Site


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •