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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:39:03+00:00 2026-06-06T10:39:03+00:00

I have a sitewide include file that I include in pages in the main

  • 0

I have a sitewide include file that I include in pages in the main directory. However, I have put a bunch of pages with a common theme in a subdirectory. These pages need to reference the same include file. I am now running into problems with relative links in the include file for things like images since they call different paths depending on whether the main file is in the main directory or a sub-directory. For example, the link "images/pic.jpg" will work if the include is called from the main directory but will try to go to "sub/images/pic.jpg" if the include is called from the sub-directory.

I had solved this by using hard links that go back to the root as in /images/pic.jpg. However, I’d rather not use hard links as they may break if the site is moved to another directory etc.

Do all your pages calling a given include have to be in the same directory? Or is there some technique to get relative links in the include to work, even if the include is called from a sub-directory?

Many thanks.

  • 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-06T10:39:05+00:00Added an answer on June 6, 2026 at 10:39 am

    There are no hard and fast rules – you can deal with your includes as you want, but you should endeavour to be consistent.

    The largest site I managed had thousands of include files scattered through hundreds of subdirectories. We used absolute paths throughout, using one variable to denote the root directory, and then concatenating the rest of the path on as required. When we needed to move the files, we needed to change that one variable, and the whole site moved.

    You can use relative links, but I found them a lot more confusing when you’re trying to figure out what files are being called from where.

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

Sidebar

Related Questions

Hey everyone, I have the smoothscroller script implemented in a sitewide include file. But
php file to be available sitewide such that without require or include i simply
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
To aid navigation we would prefer our users to only create pages that have
I have a whole bunch of HTML code throughout pages on my website and
Have a matrix report now that has Position, Hours and Wages for a location
Different pages of my site have different js needs (plugins mainly), some need a
i have setup a profanity filter with bad words in a XML file and
We have a small .Net program that we sell with individual licenses. The individual
I have over 11,000 pages in a site and need to change the tag

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.