Forum Moderators: open

Message Too Old, No Replies

SSI includes are nesting multiple times

What am I doing wrong?

         

cws3di

6:19 pm on Oct 7, 2005 (gmt 0)

10+ Year Member



I use SSI includes on most of my websites - I design them in from the start of almost every project these days because it makes things easier for site-wide updating of headers, footers, or menu bars.

Today I discovered something in my logs that has all but panicked me! Someone came into the site calling the .html page twice, and rather than a 404 error (I would expect one!) they received a 200OK. I investigated, and found that my pages come up if you call the .html file twice, e.g.

www.example.com/page1.html/page1.html

Each place on the page where I have called an include, the "page1.html" starts over, nested inside of "page1.html"

Here is how I set up the SSI include in my pages:

<!--#include virtual="menubar.html" -->

my .htaccess file has these lines near the bottom of the file

#This is to parse all .html files for SSI includes
AddType text/html .html
AddHandler server-parsed .html

My ssi includes work perfectly fine, calling in the correct code that is in the menubar.html file, if the correct url is used, e.g. www.example.com/page1.html

This nesting thing really has me scratching my head. Does anyone have a suggestion for an alternate method that doesn't allow this to happen?

encyclo

12:42 am on Oct 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One issue that I can see is that your include files have the file extension .html, which is the extension that you use for your actual pages that you have parsed for SSI.

With SSI, as you are dealing with only snippets of markup not whole HTML documents, it is good practice to use a different extension for the include files. I prefer using .inc, and many use .txt - but using either will ensure that the includes are not parsed for further includes, which is maybe one possibility for what is causing your "loop".