Set up Apache2 to handle .html files the way php 8.0 does
P粉670838735
P粉670838735 2024-01-16 11:25:21
0
1
386

I have set up php/apache according to this linode guide: https://www.linode.com/docs/guides/install-php-8-for-apache-and-nginx-on-ubuntu/

This seems to work, I have an apache server that serves files and handles .php files.

However, I'm taking the time to figure out how to tell apache to use .php to handle .html files. Anything I do with .htaccess (a-la- https://manage.accuwebhosting.com/knowledgebase/2492/Parse-HTML-As-PHP-Using-HTACCESS-File.html etc.) Modifications will not produce any changes. I also set AllowOverride All to /etc/apache2/apache2.conf in the /var/www/ directory. Additionally, most online information on the subject points to earlier versions of .php, with no specific mention of 8.0.

What can let apache use 8.0 to process .html?

P粉670838735
P粉670838735

reply all(1)
P粉373990857

You need this module, confirm you have this line in httpd.conf, or add it to it:

LoadModule mime_module modules/mod_mime.so

Also check if the modules/mod_mime.so file exists on your system.

Then find or add the module section in httpd.conf:


    # following line will change mime type of .html file to php
    # and they will be handled as such
    AddType application/x-httpd-php .html

Directive AllowOverride All will enable .htaccess files, but you also need to enable mime_module.

Of course, restart the apache server after changing the configuration.

Module documentation: here

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!