TurnKey Linux Virtual Appliance Library

LAPP PHP in .html

I would like to configure apache to execute php scripts w/in .html documents.

i.e. this text in a file named phptest.hrml:

<html>

    <head>
        <title>PHP in HTML Test</title>
    </head>
    <body>
        <ul>
            <?php for($i=1;$i<=5;$i++){ ?>
            <li>Menu Item #<?php echo $i; ?></li><?php } ?>
        </ul>
    </body>
</html>
 

Have tried multiple variations of .htaccess with no luck.

Seems like this sould be pretty straight forward.

Jeremy's picture

Ummm, why not just rename the file?

If you rename the file phptest.php the html will still work fine and so will the php. Should then just work OOTB - no apache config required...

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)