重定向后使用未定义的常量DIR_INCLUDE

I have wriiten a index.php in my root directory(i.e. classroom folder in my case).which is supposed to be the only entry path of my website.

first few lines of my index.php is

index.php

<?php
     include_once $_SERVER['DOCUMENT_ROOT'].'/classroom/include/db.inc.php' ;
     session_start();
     define('BASE_URL', '/classroom/');
     define('DIR_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
     define('DIR_HOME', DIR_ROOT . 'home' . DIRECTORY_SEPARATOR);
     define('DIR_INCLUDE', DIR_ROOT . 'include' . DIRECTORY_SEPARATOR);
     if(isset($_GET['name']) and $_GET['name'] == 'home' )
     {
          $url='';
          $url= BASE_URL . 'home' . DIRECTORY_SEPARATOR;
          header("Location: $url");
          exit();
     }

now in home directory it will load the home.html.php.now when am try to use 'DIR_HOME' or 'DIR_INCLUDE'.its showing a error message

( ! ) Notice: Use of undefined constant DIR_INCLUDE - assumed 'DIR_INCLUDE' in C:\wamp\www\classroom\home\home.html.php on line 17

i am giving you the portion where the error occurred in my home.html.php

home.html.php

<table width="100%" border="0" cellpadding="4px" >
<tr>
 <td>
<table border="0" width="100%" cellpadding="0px" cellspacing="0px">
    <tr>
        <td class="top">
                <?php include(DIR_INCLUDE . 'topper.html.php') ; ?> 
        </td>
    </tr>

the problem is solved when i am including home.html.php in my index.php.but then its not following the url like localhost/classroom/home its always remaining as localhost/classroom.

QUESTION :why this error is coming??how to solve it by keeping the url like localhost/classroom/home

EDIT: i think there is some misinterpretation.my question is how can i solve the problem while it will keep the url as localhost/clasroom/home...and if i include all dir definition in every script then same way i will alsso be needed to include session_start() in every script..my question is if i do so will it then hold single entry path concept.because i want to maintain the single entry path

Your problem is that you're mixing responsibilities. index.php should not contain bootstrap events, including that constant definitions.

bootstrapper should always be separated file, in most cases it should define only common constants and init common variables as well.

 <?php

 /* File : bootstrap.php */

 include_once $_SERVER['DOCUMENT_ROOT'].'/classroom/include/db.inc.php' ;

 session_start();

 define('BASE_URL', '/classroom/');
 define('DIR_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR);
 define('DIR_HOME', DIR_ROOT . 'home' . DIRECTORY_SEPARATOR);
 define('DIR_INCLUDE', DIR_ROOT . 'include' . DIRECTORY_SEPARATOR);

Your index.php

 <?php

 require(dirname(__FILE__) . '/bootstrap.php');

 if(isset($_GET['name']) and $_GET['name'] == 'home' )
 {
      $url='';
      $url= BASE_URL . 'home' . DIRECTORY_SEPARATOR;
      header("Location: $url");
      exit();
 }

And your home.html.php

<?php require(dirname(__FILE__) . '/bootstrap.php'); ?>

<table width="100%" border="0" cellpadding="4px" >
<tr>
 <td>
<table border="0" width="100%" cellpadding="0px" cellspacing="0px">
    <tr>
        <td class="top">
                <?php include(DIR_INCLUDE . 'topper.html.php') ; ?> 
        </td>
    </tr>

That's just a demonstration to make it work. In real-world you should not code this way. Learn about SOLID principles, OOP and MVC