How to include the header and footer in html file?

Discussion in 'HTML & Website Design' started by hhheng, Jun 18, 2007.

  1. #1
    A few of my website is static and saved as html files, but every page has the same header and footer. For the php files, we can use <? include header.php; ?>. But for those html files, how to make 1 header file and then include it into each static page?
     
    hhheng, Jun 18, 2007 IP
  2. Katy

    Katy Moderator Staff

    Messages:
    3,490
    Likes Received:
    513
    Best Answers:
    7
    Trophy Points:
    355
    #2
    Katy, Jun 18, 2007 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    You may use server side includes without renaming the files by setting the XBitHack on. Google is your friend.

    cheers,

    gary
     
    kk5st, Jun 18, 2007 IP
  4. Raz2133

    Raz2133 Peon

    Messages:
    65
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Another option would be to enable the parsing of PHP in your HTML files using a directive in your .htaccess file. This way, you could still use the PHP includes. See the article linked below for more details.

    http://www.desilva.biz/php/phpinhtml.html

    Mark
     
    Raz2133, Jun 18, 2007 IP
  5. Will Morgan

    Will Morgan Peon

    Messages:
    70
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ignore this, the poster is not very well informed of using .htaccess:
    Read this instead:
    Just open your .htaccess file and add this line:
    Addhandler application/x-httpd-php .html

    Where .html is the general file extension of your site.
     
    Will Morgan, Jun 19, 2007 IP
  6. hhheng

    hhheng Banned

    Messages:
    2,633
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hello Raz2133 and Will Morgan,

    Both are not working, please go to www.hkhangfong.com/test.php, and use the view source function to check the code.

    I created a new .htaccess file add the script as you said, but they were not working.
     
    hhheng, Jul 14, 2007 IP
  7. Will Morgan

    Will Morgan Peon

    Messages:
    70
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Ah sorry dude. What are your header and footer files called? You could try this:

    <?php
    include 'header.php';
    /* your page content here */
    include 'footer.php';
    ?>
    Code (markup):
    Let me know how you get on! (And by the way, your server is 404ing for me)
     
    Will Morgan, Aug 1, 2007 IP