Run .html files as PHP in Apache
On Ubuntu, to execute .htm files as PHP, create file
1 |
vi /etc/apache2/conf-enabled/php-html.conf |
Add following content
1 2 3 |
<FilesMatch ".+\.html$"> SetHandler application/x-httpd-php </FilesMatch> |
This is similar code from your PHP configuration. In this case, it is from /etc/apache2/mods-available/php5.6.conf
If you want it only for a specific website, edit VirtualHost entry for the website and add
1 2 3 |
<FilesMatch "\.(php|html|htm)$"> SetHandler application/x-httpd-php </FilesMatch> |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<VirtualHost *:80> ServerName serverok.in ServerAlias www.serverok.in DocumentRoot /home/www/serverok.in/html CustomLog ${APACHE_LOG_DIR}/serverok.in.log combined <Directory "/home/www/serverok.in/html"> Options All AllowOverride All Require all granted Order allow,deny allow from all </Directory> <FilesMatch "\.(php|html)$"> SetHandler application/x-httpd-php </FilesMatch> </VirtualHost> |
Now restart apache
1 |
service apache2 restart |