Help - Search - Members - Calendar
Full Version: I cant get this include code to work
HTMLHelp Forums > Web Authoring > General Web Design
nWo Sting
I have figured out includes and am having no problem with .php includes, however I have to name the pages .php for it to work. This is fine for making new pages or sections to my site. The problem with that is I have existing .htm pages that I want to incorporate an include code in, and do not want to change .htm extenstion to .php because I would have to start all over again with the site showing up in search engines. Anyway I tried this code...

<!--#include virtual="/urlpath/to/myfile.htm" -->

...and I cant get it to work. What am I supposed to replace the names with? Lets say that I am using "header.htm" as the include, and it is located under a directory on my site titled "flash". Would the code work like this??

<!--#include virtual="/flash/to/header.htm" -->

Or do I have to take the word "to" out? Or do I have to put my full URL in?

<!--#include virtual="/mysite.com/flash/to/header.htm" -->

Had I originally made my extensions .php I would have no problem, but can anyone help write the code for me since it is .htm? I would need to know exactly how to write the code, thanks in advance.........By the way my .php include codes I use are real simple like this <?php include("header.php"); ?>

pandy
QUOTE(nWo Sting @ Mar 1 2007, 07:32 AM) *

I have figured out includes and am having no problem with .php includes, however I have to name the pages .php for it to work. This is fine for making new pages or sections to my site. The problem with that is I have existing .htm pages that I want to incorporate an include code in, and do not want to change .htm extenstion to .php because I would have to start all over again with the site showing up in search engines.

You could make the server parse .html files for PHP.


QUOTE
<!--#include virtual="/urlpath/to/myfile.htm" -->

...and I cant get it to work. What am I supposed to replace the names with? Lets say that I am using "header.htm" as the include, and it is located under a directory on my site titled "flash". Would the code work like this??

<!--#include virtual="/flash/to/header.htm" -->

Or do I have to take the word "to" out? Or do I have to put my full URL in?



Yes, the /path/to... is meant as an example path, not part of the syntax. So if the the directory called "flash" is inside your main folder (document root) it should be like this.

CODE
<!--#include virtual="/flash/header.htm" -->
nWo Sting
Thanks, I tried and this code <!--#include virtual="/flash/header.htm" --> worked just fine for me.

Just wondering, are there any known problems with this type of code not working with certain browers, or am I pretty much going to have no worries with it not showing up for visitors?

This forum is amazing, I have learned so much off you guys, and also from the tutorials on the site. And to think this one guy I know in person said I was stupid for refusing to use frames on my site. CSS and include codes are so much better than frames. Thanks!
pandy
No, that's the good part. Browsers don't even come into play. Everything happens on the server before the browser sees it. The browser is served a normal HTML page. View Source and see for yourself. If it works, it works. And that's it. If there are problems with a browser, it's because of your HTML/CSS.

BTW, should you want to use PHP with the .html extension, on Apache you add this in your .htaccess file.
CODE
AddHandler application/x-httpd-php .html
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.