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 8578479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:23:56+00:00 2026-06-11T20:23:56+00:00

I am having problems with locating files with php include on my Ubuntu server.

  • 0

I am having problems with locating files with php include on my Ubuntu server.

structure of site

/var/www/
     home/index.php
     include/header.php

When I try to insert the following include_once('/include/header.php') in the file home/index.php it does not work.

however if I change that to include_once('../include/header.php'), it works fine, but to have consistency through out my site I can’t allow this

What is the best way to fix this?

  • 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-06-11T20:23:57+00:00Added an answer on June 11, 2026 at 8:23 pm

    If your document root is /var/www/ then you can use:

    include $_SERVER['DOCUMENT_ROOT'] . '/include/header.php';
    

    Typically, PHP gets the DOCUMENT_ROOT correct so you can usually rely on that.

    If you want to include the file relative to the script that is doing the include, you can do:

    include dirname(__FILE__) . '/../include/header.php';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im having problems with the following code: for (var i:Number=0; i<numFaces;i++){ var faceLoader:Loader =
I am having problems with my php includes and I am wondering if someone
I've been having problems with the indentation of my XML files. Everytime I load
Having problems getting glassfish to even run on my server. jRuby is absoutely maddening
I having problems setting the child index of a sprite... It works perfectly on
Im having problems trying to install the HtmlAgilityPack.dll ver 1.4. I've copied the files
i having problems using this code in order to include a photo in my
I having problems when I am trying to parse emails through PHP imap functions
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume

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.