Apache parse .html file to php
If your html file has php include. And you dont want to change the file type to php. Just want to make Apache to treat html file as php file. you can follow this
- Create index.html file
html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<?php echo "This is PHP Code"; ?>
</body>
</html>
- Create a test site use PWS. Choose a php version. like php8.2. Add this to php-fpm.conf [www] block.
sh
security.limit_extensions = .php .php3 .php4 .php5 .php7 .html .htm
- Add this to site's apache vhost file. you should change 'phpwebstudy-php-cgi-82.sock' to you choosed php version
sh
<FilesMatch .html$>
SetHandler "proxy:unix:/tmp/phpwebstudy-php-cgi-82.sock|fcgi://localhost"
</FilesMatch>
- Start Apache and PHP. Open the website in the browser and view the results