Plain HTML files (without any PHP) display correctly
However, HTML files that contain <?php require('./wp/wp-load.php'); ?> to load WordPress do not work — the PHP is not being processed and WordPress does not load
What I have tried:
Router Mode is set to “site domains”
I have also tried changing the web server settings:
When using nginx, WordPress is not loaded
When using Apache, I get a 502 error
The site works fine on the production server
Is there a way to configure Local so that PHP is processed in HTML files outside the WordPress directory?
Thank you for your response! Changing the file extension to .php worked correctly.
However, this method requires me to change all .html files to .php in Local, and then change them back to .html when deploying to the production server, which is a bit inconvenient.
Is there any way to process PHP in .html files without changing the file extension?
Stop the site and start it again. (The config changes will not apply until you do this.)
PHP should now load in your local HTML files. You will have to make these changes to any local sites where you want to treat HTML as PHP files. You would also have to modify production servers in a similar way if you haven’t yet. (Most do not load PHP in HTML by default.)
I followed the steps, but I noticed that the line location ~ \.php$ { does not exist in my nginx.conf.hbs file. I’ve pasted the full content of the file below — could you let me know what I should look for instead, or where this line might be located in a different format?
Also, I edited the www.conf.hbs file by adding security.limit_extensions = .php .html .htm below [www]. I’ve pasted the full content of this file as well — could you confirm whether this is correct?
{{! This file will not be used on Windows due to PHP-FPM not being available on Windows. }}
[www]
security.limit_extensions = .php .html .htm
listen = "{{phpFpm.socket}}"
pm = static
pm.max_children = 2
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
catch_workers_output = yes
{{! Environment Variables for ImageMagick }}
env[MAGICK_CODER_MODULE_PATH] = "{{imageMagick.codersDir}}"
env[GS_LIB] = "{{imageMagick.ghostscriptLib}}"
Sorry, @taka, the first file you need to edit is conf → nginx → site.conf.hbs (not nginx.conf.hbs). I edited the steps above with the correct file name.
Thank you for the clarification! I edited site.conf.hbs as instructed and it is now working correctly. The HTML files are now processing PHP as expected.