homepage Welcome to WebmasterWorld Guest from 54.211.190.232
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Server Side Includes
tonynoriega




msg:4114451
 5:38 pm on Apr 12, 2010 (gmt 0)

I am using a hosted server, and trying to set up some includes on my site... i have done this with PHP on a linux server but not with HTML on a Win server..

Server: Win 2003 Enterprise Server

CGI Active

Pages are HTML.

i created an includes folder.

i created: nav.shtml

Per my server notes in the Cpanel it says: "Required SSI filename extensions: .shtml"

in my index.html page i used the line:
<!--#include virtual="includes/nav.shtml"-->

and other various tries... what am i missing?

can i not use html pages, do they have to be .asp pages to call the include?

 

LifeinAsia




msg:4114455
 5:46 pm on Apr 12, 2010 (gmt 0)

in my index.html page

I think you need to use index.shtml

The .shtml alerts your web server to parse that file differently than static HTML files.

Unless you have another include in the included file, you probably want to use:
<!--#include virtual="includes/nav.html"-->

MichaelBluejay




msg:4114870
 7:11 am on Apr 13, 2010 (gmt 0)

Yes, you have the html/shtml backwards. .shtml is for the calling page, .html is for the called page. Actually, the called page can have whatever extension you want. I typically use .ssi, for example.

Also, if you put this code into your .htaccess file, then it doesn't matter whether your pages end with .shtml or .html:

AddHandler server-parsed .html

All of the above works for Apache web servers, but I assume it'll work for Windows, too.

rocknbil




msg:4115284
 6:27 pm on Apr 13, 2010 (gmt 0)

The included file can be pretty much anything. <strong>However, the space before --> is extremely important.</strong>


<!--#include virtual="includes/nav.html" --> (in this case)

<!--#include virtual="includes/nav.txt" -->

<img src="<!--#include virtual="/images/some-image.gif" -->" alt="img">

<!--#include virtual="/cgi-bin/some-script.cgi" -->

MichaelBluejay




msg:4115443
 12:37 am on Apr 14, 2010 (gmt 0)

What's important about the space before the "-->"? I've never included that space, and I've never had any problems...that I know of.

rocknbil




msg:4115903
 6:58 pm on Apr 14, 2010 (gmt 0)

I can't even remember, all I recall is battling it one day and the space was what fixed it. One of those things you learn and forget about **why.**

Closest I found was this [w3u.net], (mods, nix the link if inappropriate) in reference to using echo:

When you forget to leave a space before the closing SSI command HTML tag (-->), or when you add a space between the hash sign (#) and the SSI command (<!--# echo), nothing works, and you get that silly and ever-so-helpful error message ["an error occurred while processing this directive"].


If you note all the examples [httpd.apache.org], they have spaces.

MichaelBluejay




msg:4116948
 3:49 pm on Apr 16, 2010 (gmt 0)

Okay. But it's worked for me 100% of the time without the space, for years, so I think I'll likely keep doing it that way.

kaled




msg:4117174
 1:37 am on Apr 17, 2010 (gmt 0)

The space may be optional on some systems and mandatory on others. Since it is harmless, it's probably best to include it.

Kaled.

tedster




msg:4117362
 4:20 pm on Apr 17, 2010 (gmt 0)

kaled nails it -- there are lots of technical areas where many systems now recover from common errors, but it's still best not to make them in the first place.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved