SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_SERVER['DOCUMENT_ROOT'] from Apache to IIS - HELP!

    I'm moving some PHP scripts from Apache to IIS and the $_SERVER['DOCUMENT_ROOT'] isn't working properly. I've found some code I can use to replace the current code but I'd much prefer a config solution since there are a lot of scripts to move over...

    Thanks
    "If all else fails brute force is always an option."
    M.E.

  2. #2
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this. But I don't deal with IIS myself so I have no idea if it works:
    PHP Code:
    if (!isset($_SERVER['DOCUMENT_ROOT']))
    {
        
    $_SERVER['DOCUMENT_ROOT'] = substr($_SERVER['SCRIPT_FILENAME'] , , -strlen($_SERVER['PHP_SELF'])+1);

    ~ Daniel Macedo

  3. #3
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, that's the code I found. I'm looking for a server config solution so I don't have to go through all the scripts.

    Thanks
    "If all else fails brute force is always an option."
    M.E.

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    You could make save the above script and use the auto_prepend_file config option to automatically prepend the script to all documents.

  5. #5
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Immerse
    You could make save the above script and use the auto_prepend_file config option to automatically prepend the script to all documents.
    I've never heard of that. How do I do that?
    "If all else fails brute force is always an option."
    M.E.

  6. #6
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks all!

    The prepend option seems to be working!
    "If all else fails brute force is always an option."
    M.E.

  8. #8
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Don't forget that if you ever move to a different server, you might need to change auto_prepend_file setting there too

  9. #9
    SitePoint Zealot dustbuster's Avatar
    Join Date
    Jan 2003
    Location
    End-World
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks
    "If all else fails brute force is always an option."
    M.E.


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
  •