Jump to content

Recommended Posts

Posted

OK, I'm trying to figure out how to use the php include function in an HTML page. I'm trying to build a navigation menu page that I want to insert into all my pages.

 

I have created a file called "nav.html" which I want to embed into other .htm & .html pages.

 

In my sample html page I am playing with I added the following:

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/nav.html";

?>

 

Both files are in the public_html folder. Do I have to add anything to the .htaccess file for "php" to work in .htm and .html files?

 

Here is a sample page I am trying to test this with.

www.pdabruce.com/css1.htm

 

Thanks in advance for any pointers. ;)

Posted

In short, yeah you have to add something to your .htaccess file to get html files parssed by the php interpreter.

 

Try adding this to .htaccess:

 

>AddType application/x-httpd-php .htm .html

Posted

If you don't have your pages published yet, then you could just change them from .htm/.html files to .php files. Then you wouldn't have to change your htaccess file. If you do already have them published, you could still make the change to .php and then do a redirect in the htaccess file. You would want someone besides me to help you with that, though!!

 

I've started using .php files almost exclusively because of the few tidbits of php code that I use.

Posted

Well since the site is over a year old and has a decent page rank I would prefer to leave them as .htm and .html for now. I'm in the process of a site redesign and don't want to lose any of the traffic I am currently getting.

 

And this solution works fine, since I only want to use if for the navigation section of the site.

 

Thank you for your comments. ;)

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...