Hello All,

I do not know much at all about PHP except for the include function.

I was in the process of putting a site together when my host SteadFast went from a PHP 4 w/apache (<-- I beleive Apache) server to a PHP 5 w/ Litespeed server.

I used to write my includes as

<?php include("http://mysite.com/header.html"); ?>

well after the upgrade these stopped working. I messed around with them based on the onscreen error messages I was getting and by solutions found via Google and finally came to realize that this worked...

<?php include ("/hsphere/local/home/myaccountname/mysite.com/header.html"); ?>

I also changed my .htaccess file which used to read only

AddHandler application/x-httpd-php htm html

on the old server to...

AddHandler php5-script htm html php
AddType text/html php

on the new server.

I have a few questions about this though.

  1. Why did I even need to change it what about PHP 5 caused the old method not to work.

  2. What do the lines in my .htaccess actually do ? I found that they were a solution but I have not read of anyone that explains why it works and what the lines are actually doing.

  3. When I was looking for solutions I read that PHP 5 used relative paths for example...

<?php include ("header.html"); ?>

when I tried it I got the error message that led me to add the...

/hsphere/local/home/myaccountname/mysite.com/

which ended up working but no ones solution called for doing that WHY ?

How is it that other people that asked the question were told to start at thier personal sites root and I have to use the root all the way back to my host company ?

  1. Is any of the changes I made a security risk or do they slow things down in any way ? Is there a way to get the same effect and be more efficient in speed security etc ?

  2. What is the difference between Apache and Litespeed and is this playing any part in this ?

    I suspect the problem was that the new hosting configuration disabled the ability to include files via URL as a security precaution, thus you had to use a file-system path, instead. You can make your includes less dependent on the specific directory names under which your site is located by including it relative to the web site's document root directory, e.g.:

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

    You could also set an include_path setting in your .htaccess to point to where your include files are. For instance, if you put them in a directory called "include" directly under your site's root diretory, you would set:

    php_value include_path /hsphere/local/home/myaccountname/mysite.com/include/
    

    The other stuff in your .htaccess file is telling the web server to send files with the .htm r .html suffix to the PHP parser/compiler (in addition to the .php files).

      of the 2 methods above which one is betterand why ?

      or is it better to type out the root all the way back like I am currently ?

      TIA

        I would use the $_SERVER['DOCUMENT_ROOT'] method in preference to typing out the entire path, as it will continue to work even if you move your site to a new host, or the current host changes its directory structure, as long as your web site's directory structure does not change.

        Setting up an include_path is even simpler as far as your scripts go, as then you only have to type the file name (or sub-directory and file name if it's in a sub-directory of one of your include_path directories). Either method has its pros and cons, I suppose. I think the include_path option gives you the most flexibility, as if you decide you need to move or rename the directory where your include files are, you only need to change the include_path setting in one place.

          Write a Reply...