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

  • Home
  • SEARCH
  • 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 6713237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:21:19+00:00 2026-05-26T08:21:19+00:00

this is how my file structure is. [..] are folders [public] [libs] [crontab] [logs]

  • 0

this is how my file structure is. [..] are folders

[public]
[libs]
[crontab]
[logs]
[sessions]
[tmp]

config.php

the domain is set to the public folder as its root. everything else including the config.php file is outside the root. the config contains db connection information and other necessary settings.

every page in the public folder i have to put the entire path so include the config file. problem is when i move everything from my local machine to the public server i have to go through every page and change the path included for the config file. is there a better way? maybe settings a path in php.ini or something like that?

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-05-26T08:21:20+00:00Added an answer on May 26, 2026 at 8:21 am

    In that specific case you can use:

    include("$_SERVER[DOCUMENT_ROOT]/../config.php");
    # Note: special exception array syntax within double quotes.
    

    Which resolves to the public directory first, but moves one level back ../ to reach the config file outside of the docroot.


    But you could also use SetEnv in your .htaccess to define another $_SERVER environment variable for the occasion.

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

Sidebar

Related Questions

this is my php folder/file structure: mvc controller login.class.php model login.class.php lib login.class.php core
I would like copy just file.xml without folder structure using overlays like this: <overlays>
This is the code I'm using (it's the index.php file) /* Set an include
I have this file structure: folderIWantStuffIn/ - old_stuff Now I want to add some
Here's the folder structure of my project: /ping --/Controller ----Ping_Conntroller_Main.php ----Ping_Conntroller_Db.php --/Model ----dbCredentials.php --/View
I have a file structure like this: 00000010 000000001.file1 000000001.file2 00000020 00000003.file1 00000003.file2 00000003.file3
I have the following PHP code to display the file structure of my site.
I'm working on this app to gather some file/folder usage data. The goal is
I'm new to PHP. I'm developing a new PHP website. My website folder structure
This program reads emails (really just a .txt file structured like an email) and

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.