php include question

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.<br /><br />I have created a file called "nav.html" which I want to embed into other .htm & .html pages.<br /><br />In my sample html page I am playing with I added the following:<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><?php<br />include $_SERVER['DOCUMENT_ROOT']."/nav.html";<br />?><!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />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?<br /><br />Here is a sample page I am trying to test this with.<br /><a href="http://www.pdabruce.com/css1.htm" target="_blank">www.pdabruce.com/css1.htm</a><br /><br />Thanks in advance for any pointers. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
In short, yeah you have to add something to your .htaccess file to get html files parssed by the php interpreter.<br /><br />Try adding this to .htaccess:<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->AddType application/x-httpd-php .htm .html<!--c2--></div><!--ec2--><!--content-->
Thank you! That worked! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
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!!<br /><br />I've started using .php files almost exclusively because of the few tidbits of php code that I use.<!--content-->
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.<br /><br />And this solution works fine, since I only want to use if for the navigation section of the site.<br /><br />Thank you for your comments. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
 
Back
Top