Skip to main content
Participating Frequently
Mar 23, 2017 1:30 AM UTC
Answered

How to embed PHP code in HTML document [was:Dreamweaver CC 2017]

I'm trying to embed PHP code inside an HTML page with a .html file extension. If I look at the local file using MAMP with a browser, it displays correctly. However, Dreamweaver refuses to parse the PHP content properly when it's located in an HTML file. Is there someway to enable this, like modifying a .htaccess file on a real server to accomplish the same thing?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    BenPleysier
    BenPleysierCorrect answer
    Community Expert
    Mar 23, 2017 1:43 AM UTC

    Dreamweaver will only help you with PHP when the file is appropriately named with a PHP extension. You can then change the extension in the .htaccess file by adding

    RewriteEngine on
    RewriteRule ^(.*)\.html$ $1.php

    When you access index.html the system will look for a file called index.php

    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!

    2 replies

    BenPleysier
    Community Expert
    BenPleysierCommunity ExpertCorrect answer
    Community Expert
    Mar 23, 2017 1:43 AM UTC

    Dreamweaver will only help you with PHP when the file is appropriately named with a PHP extension. You can then change the extension in the .htaccess file by adding

    RewriteEngine on
    RewriteRule ^(.*)\.html$ $1.php

    When you access index.html the system will look for a file called index.php

    Translate
    Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
    Participating Frequently
    Mar 23, 2017 2:22 AM UTC

    This works perfectly. Thank you for your prompt and expert answer!

    Translate