Forum

How to Parse HTML Files As PHP

Fred
27 April 2016, 12:54
Hi Hugo,

We curently have a website that is witten in shtml but we use .htaccess to translate the shtml page to PHP
AddHandler application/x-httpd-php .shtml
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Could you please tell me how to translate this into Hiawatha?
We've added this code in Hiawatha but not all the script on the page is showing
CGIhandler = /usr/local/bin/ssi-cgi:shtml
CGIhandler = /usr/local/bin/php-cgi:php
#CGIhandler = /usr/local/bin/php-cgi:shtml
FastCGIserver {
FastCGIid = PHP5-FPM
ConnectTo = /var/run/php-fpm.sock
Extension = php
}


Thank you
Hugo Leisink
27 April 2016, 13:45
You're sure you want PHP to handle .shtml files?? If you are, simple use this configuration:
FastCGIserver {
FastCGIid = PHP5-FPM
ConnectTo = /var/run/php-fpm.sock
Extension = php, shtml
}

Use the UseFastCGI option in each virtual host that is allowed to execute PHP scripts.
Fred
27 April 2016, 15:53
Hi Hugo,
I know it sound wierd but I didn't deigned it... so we need PHP to handle .shtml files
I ahd tried the solution you offered prior to posting on the forum as I found this post here https://www.hiawatha-webserver.org/forum/topic/749/#4925
The problem when I used the above, none of the ssi or showing on the page anymore
here is a snippet of my config
CGIhandler = /usr/local/bin/ssi-cgi:shtml
CGIhandler = /usr/local/bin/php-cgi:php
#CGIhandler = /usr/local/bin/php-cgi:shtml
FastCGIserver {
FastCGIid = PHP5-FPM
ConnectTo = /var/run/php-fpm.sock
Extension = php
}
FastCGIserver {
FastCGIid = PHP5_SHTML
ConnectTo = /var/run/php-fpm.sock
Extension = php, shtml
}
VirtualHost {
...
StartFile = index.shtml
UseFastCGI = PHP5_SHTML
...
}

Do I need a UrlToolkit like in this post ?
https://www.hiawatha-webserver.org/forum/topic/966/#5898
Hugo Leisink
27 April 2016, 17:19
I can't solve issues with weirdly written applications. A bug in Hiawatha, that's one thing I can solve. Perhaps contact the author of the shtml files?
Fred
28 April 2016, 00:20
Hugo,
I have been told that its comom practice to do the above.
The site is all static but we want to display a dynamic shopping cart..

Do you have any other sugestion to offer at all?

Thank you
Fred
Fred
28 April 2016, 12:44
Hi Hugo,

I took a step back here and I created a very simple test.shtml page with the following:
<!DOCTYPE html>
<html>
<body>

<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include 'footer.php';?>

</body>
</html>

In the same directory I create the footer.php with
<?php
echo "<p>Copyright &copy; 1999-" . date("Y") . " W3Schools.com</p>";
?>


When I go to mydomain.com/test.shtml I can see
Welcome to my home page!

Some text.

Some more text.
but not the footer.
Could you please help me to get this simple code to work and i'll take it from there please.
so far this is what I have
CGIhandler = /usr/local/bin/ssi-cgi:shtml
CGIhandler = /usr/local/bin/php-cgi:php
FastCGIserver {
FastCGIid = PHP5_SHTML
ConnectTo = /var/run/php-fpm.sock
Extension = php, shtml
}
VirtualHost {
...
StartFile = index.shtml
UseFastCGI = PHP5_SHTML
...
}
Hugo Leisink
28 April 2016, 13:15
Did you disable the "CGIhandler = /usr/local/bin/ssi-cgi:shtml" setting?
Fred
28 April 2016, 13:22
Hi Hugo,

no I didn't but i've got that simple script working

Thank you
This topic has been closed.