Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6379553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:09:11+00:00 2026-05-25T02:09:11+00:00

I am back with a simple question (or related question). The question is simple

  • 0

I am back with a simple question (or related question).

The question is simple however I have not received an answer yet. I have asked many people with different experience in PHP. But the response I get is: “I don’t have any idea. I’ve never thought about that.” Using Google I have not been able to find any article on this. I hope that I will get a satisfying answer here.

So the question is:

What is the difference between $_SERVER['DOCUMENT_ROOT'] and $_SERVER['HTTP_HOST'] ?

Are there any advantages of one over the other?

Where should we use HTTP_HOST & where to use DOCUMENT_ROOT?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:09:12+00:00Added an answer on May 25, 2026 at 2:09 am

    DOCUMENT_ROOT

    The root directory of this site defined by the ‘DocumentRoot’ directive in the General Section or a section e.g.

    DOCUMENT_ROOT=/var/www/example 
    

    HTTP_HOST

    The base URL of the host e.g.

    HTTP_HOST=www.example.com 
    

    The document root is the local path to your website, on your server; The http host is the hostname of the server. They are rather different; perhaps you can clarify your question?

    Edit:
    You said:

    Case 1 : header(‘Location: ‘. $_SERVER[‘DOCUMENT_ROOT’] . ‘/abc.php’)

    Case 2: header(‘Location: ‘. $_SERVER[‘HTTP_HOST’] . ‘/abc.php’)

    I suspect the first is only going to work if you run your browser on the same machine that’s serving the pages.

    Imagine if someone else visits your website, using their Windows machine. And your webserver tells them in the HTTP headers, “hey, actually, redirect this location: /var/www/example/abc.php.” What do you expect the user’s machine to do?

    Now, if you’re talking about something like

    <?php include($_SERVER['DOCUMENT_ROOT'] . '/include/abc.php') ?>
    

    vs

    <?php include($_SERVER['HTTP_HOST'] . '/include/abc.php') ?>
    

    That might make sense. I suspect in this case the former is probably preferred, although I am not a PHP Guru.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to this question I asked a while back. The end game
I have a simple c++ application that generates reports on the back end of
I'm trying to fetch Wikipedia pages using LWP::Simple , but they're not coming back.
I've found a similar question on SO , however, that seems not exactly what
This question relates to Django Aggregation/Annotation in 1.1. Suppose I have a simple model
I asked a related question here: Clojure: How do I turn clojure code into
I got a simple question about jquery fancybox. In my recent project I have
This seems like a simple question, but I am having trouble finding the answer.
Really simple question but I can't find an answer. I know how to do
I have two tables that are related, which, for the purpose of this question,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.