Forum Moderators: phranque

Message Too Old, No Replies

Odd SSI problem

.shtml works on localhost but .htm does not

         

gmac6791

5:13 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi, this is my first time on the board, even though I've come here for help many times in the past. :) I searched for an answer to my problem but didn't find anything that relates...

I'm running the latest Apache in WinXP Home with MySQL, PHP and Perl. I'm using SSI (not by choice, in case you're wondering) for the header and footer of the pages of a website I'm building, and I'd rather not use the .shtml file extension. The problem is when using .htm, the header and footer does not show up when I preview the pages. They show up just fine if I use .shtml, but not .htm.

Please bear with me as I describe what I've tried already. In the Apache config file I have the following:

-----

Options Indexes FollowSymLinks ExecCGI Includes

AddType text/html .shtml .htm
AddOutputFilter INCLUDES .shtml .htm

-----

Anytime I made the changes to the config file, I restarted Apache. But these changes did not work. So I tried making an .htaccess file with the following:

-----

AddType text/html .shtml .htm
AddHandler server-parsed .shtml .htm
Options Indexes FollowSymLinks Includes

-----

That did not work, either, so I even tried adding a line to that code, and taking the .htm off the other lines:

-----

AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

-----

All files are their correct directories and all that. Like I said, it works fine with .shtml but not .htm.

What am I missing? :(

Storyman

6:10 pm on Nov 30, 2004 (gmt 0)

10+ Year Member



gmac6791,

This isn't an answer to your question, but rather a question to you.

Why is it you are resistant to using SSI?

When using include files, I've found the .php extension works fine. It also has the benefit of not letting users view the code.

gmac6791

7:32 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



I don't see a need for using SSI, since PHP does all that and more. My client, however, wants it to be SSI because he wants to keep the server load at a minimum. I don't know how much difference there would be, but I can't convince him to use PHP.

jdMorgan

8:10 pm on Nov 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gmac6791,

Welcome to WebmasterWorld!

I have a question, too:

> The problem is when using .htm, the header and footer does not show up when I preview the pages. They show up just fine if I use .shtml, but not .htm

What specifically do you mean by the word "preview" above. I'm asking because you must request the page from the server in order for SSI to be processed, so I want to make sure we're not talking about the SSI not being visible in an HTML editor (which would be normal). Also, an old copy of the page might be cached by your browsert, so you'll need to flush your cache after any change to the page source or to the server config.

Jim

[edited by: jdMorgan at 12:23 am (utc) on Dec. 1, 2004]

gmac6791

8:27 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



Yes, I should have clarified that. I am looking at the pages through a browser, not an editor. And when I refresh I use Ctrl+F5 for a proper refresh. I don't think I need to totally flush the cache because when I change the file extension to .shtml, it works fine. I see the desired results with a normal refresh.

Also, when I upload the pages to the company's web server, the .htm extension works, but not on localhost. This has me stumped. :(

coopster

9:38 pm on Nov 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you running the .htm files through the PHP parser as well? If so, have a look at your DOCTYPE declaration in your source after it is served up. This happened to another member recently...

[webmasterworld.com...]

gmac6791

9:46 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



AHA! I got it working finally. With this:

AddType text/htm .shtml .htm
AddHandler server-parsed .shtml .htm
AddOutputFilter INCLUDES .shtml .htm

Note the difference between that and the other ones I tried (one of which I totally forgot to add .htm
to the string :o )...

No good:


AddType text/html .shtml .htm
AddOutputFilter INCLUDES .shtml .htm

No good:


AddType text/html .shtml .htm
AddHandler server-parsed .shtml .htm

No good:


AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml

GOOD! :) :)


AddType text/htm .shtml .htm
AddHandler server-parsed .shtml .htm
AddOutputFilter INCLUDES .shtml .htm

Thanks for the replies, even though they were questions to my question. ;)

gmac6791

9:51 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



coopster wrote:
"Are you running the .htm files through the PHP parser as well? If so, have a look at your DOCTYPE declaration in your source after it is served up. This happened to another member recently...
[webmasterworld.com...] "

Yup. The only thing bugging me was that .htm did not work when everything else did. My above post explains why. It's amazing how simple things can shoot right over my head sometimes.

coopster

10:27 pm on Nov 30, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You really shouldn't need the AddHandler [httpd.apache.org] directive, unless you are doing something a little more out of the ordinary here. I think the key to your issue lies in your Content-type that you are serving up in your pages. If it is indeed
text/htm
as opposed to
text/html
, that would explain why it wasn't working.
AddType text/htm .shtml .htm 
#AddHandler server-parsed .shtml .htm
AddOutputFilter INCLUDES .shtml .htm

gmac6791

10:35 pm on Nov 30, 2004 (gmt 0)

10+ Year Member Top Contributors Of The Month



It is text/html, and has been all along.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />