Jump to content

[2 PART] Defining a root dir & defining page


timmy0320

Recommended Posts

[PART 1]

Alright I have defined some constants for my root directory of files.

 

define("ROOT_DIR", "/new_work/");
define("ROOT_URL", "http://" . $_SERVER['HTTP_HOST']."".ROOT_DIR."");

 

This function works until I use it in a sub-directory. Now I figured out that I had to turn on allow_url_include on my php.ini settings. I did that and now works. (session.php includes constants.php which contains the above constants)

 

include("../session.php");
include("".ROOT_URL."templ/header.php");

 

Now I'm making my pages all on my computer and personally hosting them before I upload anything to my Webhost. I've read that a lot of web hosts (and Yes I do plan on contacting mine) have this option turned off . I am having trouble figuring out how to do this without linking it by URL . I can do just the ROOT_DIR but then my pages in the sub-directories link wrong. Sub-directories will then link as /dir/include when it's supposed to be just /include/ from the main directory. Any tips on a better way?

 

 

[PART 2]

 

I define all my pages at the top.

 

define('MYSITE', true);

 

All of my includes are as:

 

if (!defined('MYSITE')) { exit; }

 

All of my includes are including except my header and footer and they are all setup the same way and I am lost as to why it's doing this just for those two files. Could it be the order of my includes or what's the deal with this all of a sudden not working? It's only doing it in the sub-directory and the define() are at the TOP of the page before includes.

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.