Server Side Include on plain .htm file on PHP server

I'm trying to help a client setup SSI's on his site. I believe its a Linux host, I don't have access to change any settings though:

http://www.pearson40.net/sample.htm

Code: <?php include("_head.htm"); ?>

I can't run ASP includes. I can run PHP includes, but only if I give it the PHP file extension. He has dozens of inter-linked pages with the .htm extension. Is there any way to do includes in that case, or are we out of luck? Thank you!
Brad BansnerWeb DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

stu215Systems AnalystCommented:
Assuming its linux you could use an .htaccess file to change the directory permissions to allow SSI commands.

Helpful Link:
http://www.besthostratings.com/articles/enable-cgi-php-ssi-htaccess.html

Sample .htaccess file :

AddType text/html .shtml
AddHandler server-parsed .htm
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
DirectoryIndex index.htm index.html index.shtml index.asp index.php
Options -Indexes
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brad BansnerWeb DeveloperAuthor Commented:
I made an .htaccess file and put your sample in. Reloaded page:


<!-- #INCLUDE FILE="_head.htm" -->

<p align=center style='margin:0in;margin-bottom:.0001pt;text-align:center'>&nbsp;</p>
  <p align=center style='margin:0in;margin-bottom:.0001pt;text-align:center'><b><span
  style='font-size:13.5pt;color:blue'>Go to the </span><a

So it isn't taking my SSI, or am I not doing this right?
0
stu215Systems AnalystCommented:
Try the following SSI statement to see if they are working:

<!--#ECHO var="DATE_LOCAL" -->

You may need to use:
<!--#include virtual="_head.htm" -->

Link to Wikipedia abt Virtual vs File for SSI:
http://en.wikipedia.org/wiki/Server_Side_Includes

Includes the contents of another file or the result of running a CGI script. If the process doesn't have access to read the file or execute the script, the include will fail. "virtual" specifies the target relative to the domain root, while "file" specifies the path relative to the directory of the current file. When using "file" it is forbidden to reference to absolute paths. Higher directories (..) are usually forbidden, unless explicitly configured. The Apache documentation recommends using "virtual" in preference to "file".
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

stu215Systems AnalystCommented:
Other things to check are the permissions on the .htaccess file.
[ The CHMOD of an htaccess file should be 644 or (RW- R-- R--). ]

And:  Uploading files in an FTP program happens in one of three different modes. Auto, Binary and Ascii. When you are uploading an htaccess file, it must be done in Ascii mode. To avoid all of the initial errors, make sure the setting is on Ascii.


Link to info on .htaccess files:
http://httpd.apache.org/docs/1.3/howto/htaccess.html
0
Brad BansnerWeb DeveloperAuthor Commented:
<!--#ECHO var="DATE_LOCAL" --> does work.

Changing to <!--#include virtual="_head.htm" --> does not work.

Reuploaded .htaccess making sure it was ASCII mode.

Not sure what else to do. I don't have access to the server in order to check permissions. If I can't fix this I'll have to resort to making everything .PHP files.
0
stu215Systems AnalystCommented:
If the Echo statement worked then its probably an issue with the file.

Try putting the path to the file from your server root:
<!--#include virtual="/<some folder>/_head.htm" -->

Make sure the file name is exactly the same...

Not quite sure what else to suggest :-(
0
Brad BansnerWeb DeveloperAuthor Commented:
Yeah, when I look at the source code of the page, I see this:

<!-- #INCLUDE virtual="_head.htm" -->

...so the web server isn't even processing the include as an include, its just serving that commented out code alongside all the other HTML.
0
stu215Systems AnalystCommented:
Random thought:
What if you turn on php for your .htm / .html files which would be similar to turning it on with the SSI

and use php includes:
<?php include("header.php"); ?>

Link to info about php includes:
http://www.w3schools.com/php/php_includes.asp
0
stu215Systems AnalystCommented:
Note: turning on SSI or PHP processing for all your pages creates a lot of overhead processing which can slow down your webserver so neither way is terribly great ...

I think eventually you will want to change them...

-- Doh, forgot you cant change the server settings... forget about the php includes on html files...
0
stu215Systems AnalystCommented:
If you can download the site to a local linux box or something you could do a search and replace on the whole directory to change things which wouldn't be too bad.

On windows you could use an app such as Dreamweaver CS5 which has nice site management tools and updating features.

Free Trial: https://www.adobe.com/cfusion/tdrc/index.cfm?product=dreamweaver&loc=en_us
0
Brad BansnerWeb DeveloperAuthor Commented:
OK, coo. Thanks for all your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.