InMotion Hosting Support Center

run php via shtml

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

Hits: 229
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]

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

[file: hello.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:

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.



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

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?

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:
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!