InMotion Hosting Support Center

run php via shtml


InMotionFans
n/a Points
Asked:
2014-12-07 3:36 pm EST

Hits: 227
Hello, I am trying to include/run a php file via a shtml. I have the following two files inside my public_html directory:

[file: hello.shtml]

<!DOCTYPE HTML>
<html lang="en-US">
<body>
<div>
<!--#include virtual="/hello.php" -->
</div>
</body>
</html>

[file: hello.php]

<?php
print "Hello, World!";
?>

When I try to browse to www.[my_domain].com/hello.shtml, all it shows is "[an error occurred while processing this directive]"

I know the php file has correct syntax because www.[my_domain].com/hello.php shows "Hello, World!".

I have created a .htaccess and filled it as suggested here: http://www.inmotionhosting.com/support/website/php/php-code-in-html-file?tsrc=aaq

AddType text/html .shtml .shtm .htm .html
AddHandler server-parsed .shtml .shtm .htm .html
Options Indexes FollowSymLinks Includes
AddHandler application/x-httpd-php54 .shtml

Now the error is gone but the shtml page is blank. I'd expect to see "Hello, World!"

Thanks in advance.

You must login before you can ask a follow up question.

You must login before you can submit an answer.

OTHER ANSWERS

0

TJEdens
Staff
10,077 Points
2014-12-08 11:30 am EST
Hello,

The best way to do this would to have the server treat your .shtml as a .php file by adding the following to your .htaccess:


ForceType application/x-httpd-php


Then you would be able to use the php include code to add your hello world script to your .shtml file.

Kindest Regards,
TJ Edens

You must login before you can post a comment about this answer.

Like this Question?

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!