Forum Moderators: phranque

Message Too Old, No Replies

How can I determine whether my .shtml file is making it to Apache?

My SSI includes work within Dreamweaver but not in my browser. Why?

         

Shazazzily

11:23 pm on Mar 4, 2012 (gmt 0)

10+ Year Member



I am “Running all Apache services” on my Windows 7 Professional PC, and “It Works”. I have modified the httpd.conf file to allow includes of .shtml files. Within Dreamweaver, my included HTML code shows up fine in the file into which it was included. But the SSI includes do not show up in any of my browsers.

It’s as if my .shtml file is not being parsed by Apache.

I’m new to Apache and SSI’s, but I’ve followed the help I’ve found on the internet.

I need to be able to test all my webpages on my own PC in my own browsers.

How can I determine whether my .shtml file is making it to Apache? How do I track down whether my code or my directives are in error? Thanks, if you have any ideas for me.

incrediBILL

11:30 pm on Mar 4, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Mind showing us some code with a sample of the includes?

The includes on a Windows server vs. Apache are different, sure it's the right ones?

Shazazzily

11:43 pm on Mar 4, 2012 (gmt 0)

10+ Year Member



I will gather that for you.

In the mean time, I don't know what you mean by "Windows server vs. Apache". I have Windows 7 as the underlying operating system, but am running Apache on it. The Apache icon is showing up on my Windows taskbar. I was thinking that a Windows server is something I could have gotten, but I instead downloaded Apache.

Thanks for asking, and I'll get the code to you.

g1smd

11:50 pm on Mar 4, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I rarely see people using SSI with .shtml files these days.

Have you looked at PHP includes? There's a massive amount of extra functionality to be had there.

Shazazzily

12:05 am on Mar 5, 2012 (gmt 0)

10+ Year Member



incrediBILL:

I have modified the httpd.conf file (which exists in the C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf folder) to have the following:

##### All I did was add the “+Includes” part.
<Directory />
Options FollowSymLinks +Includes
AllowOverride None
Order deny,allow
Deny from all
</Directory>


##### I simply UN-commented the 2 directives. This IfModule has more in it that I didn’t modify.
<IfModule mime_module>
#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>


In my file.shtml file I have:

<!--#include virtual="ssi-top-logos.ssi" -->


In my ssi-top-logos.ssi file, I have regular HTML code, which if were in the place of the #include directive, displays just fine. The reason I think my include syntax is correct is because the includes are displayed within Dreamweaver.

Does this give you enough to go on to start?

(I will respond to g1smd in a moment.)

Shazazzily

12:17 am on Mar 5, 2012 (gmt 0)

10+ Year Member



Thanks for raising that question, g1smd.

I have quite a bit of webpage and content developing before I’m ready to host it on the internet. So I was trying to use the simplest method of viewing and testing my pages on my own PC. I definitely need includes of some sort.

I was thinking that to make PHP work on my PC, I’d have to get a virtual server (such as Apache) anyway, but that to have Apache work, I didn’t need PHP.

However, I’m not opposed to getting PHP set up if that’s the best way. I would eventually add it anyway probably. If you have a follow up question or suggestion, I am totally open. Do you think I should drop the Apache includes and go for the other?

incrediBILL

3:22 am on Mar 5, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Virtual should work, I also use "file" on my server like this:

<!--#include file="./topnav.html" -->

Just for giggles you may want to specify a relative path, assuming the files are all they're on the same level, as that "./" seems to make some servers happy for some reason and it's totally portable as well.

What's in my .htaccess file is:

Options +Includes
AddType text/html .html .shtml
AddOutputFilter INCLUDES .html .shtml

I basically enabled all .html files for SSI as I didn't want to change to .shtml (ick!)

If all else fails, you can try the xbit hack on your file with "chmod +x yourfile.html" which tells apache to make it SSI with the +x executable bit.

Don't forget that SSI can be recursive so the type of file you include determines if it'll keep processing the SSI requests in the included file or not.

Something else to be aware of is if you have a PHP prepend, like some script running sitewide on all HTML and PHP pages, that Apache actually processes each included file with the PHP script as well. What this means is if you were running a bot blocker script for instance and had a page with 4 SSI includes, that it would run the bot blocker FIVE (5) times for one page! Once for the first page loaded and once for all 4 SSI scripts included.

Just something to be aware of that can happen as it's a real performance killer.

Shazazzily

12:30 am on Mar 6, 2012 (gmt 0)

10+ Year Member



After I’d broken things a bit further while trying to get PHP to work (without success), I put things back in order. I’m now back to the same position: Apache is running but it won’t display my included code.

I made my .htaccess file match yours. I tried changing my .shtml extension to .html. I tried “virtual” and “file”. I tried using a relative path and a full path for the included file.

I thought Apache should process all files before they get to my browser, but since it hasn’t been working, I updated the Apache httpd.conf file so that DocumentRoot and <Directory ... </Directory> are set to the location where my html files are. To no avail.

May I double-check with you, incrediBILL, is it right that you are successfully running Apache on your own computer and included files show up?

I don’t know what else to try except the xbit hack that you mentioned.

lucy24

3:41 am on Mar 6, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Something else to be aware of is if you have a PHP prepend, like some script running sitewide on all HTML and PHP pages, that Apache actually processes each included file with the PHP script as well. What this means is if you were running a bot blocker script for instance and had a page with 4 SSI includes, that it would run the bot blocker FIVE (5) times for one page! Once for the first page loaded and once for all 4 SSI scripts included.

Can't you tell it not to? "Run this script only if you're processing an .html page", that kind of thing (assuming html for the parent page and php for all the includes). Same principle as only stopping to check for Ukrainians if you're currently dealing with an html request.

fwiw, Apache says:

[httpd.apache.org...]

The author seems to be wildly in favor of XBit thingies. If only I could understand more than about one word in three...

<!--#config errmsg="[It appears that you don't know how to use SSI]" -->

incrediBILL

7:03 am on Mar 6, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can't you tell it not to? "Run this script only if you're processing an .html page", that kind of thing (assuming html for the parent page and php for all the includes). Same principle as only stopping to check for Ukrainians if you're currently dealing with an html request.


I was just explaining the perils of too much PHP enabling of .html and SSI includes because if you don't know what you're doing, or that Apache behaves that way, you can easily create a server overload.

The smart way to do it would be to PHP enable JUST the .html files but not PHP enable .shtml files and only include .shtml files as SSI, not .html files, which would avoid recursive PHP processing mess entirely.

Shazazzily

8:53 pm on Mar 11, 2012 (gmt 0)

10+ Year Member



I got my includes to work in PHP. I never could get the SSI's to work. Yes, PHP is better overall, but it seems like the SSI's should have worked somehow. Anyway, moving on with my life, I've been learning PHP. Fun!