0

A legacy application relies on the following .htaccess rule for an individual file

<Files MyFile.html>
AddType application/x-httpd-php .html
</Files>

The new machine has nginx and php-fpm installed with the following config:

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

}

2 Answers 2

0

Add another location block for your html file:

location = /path/to/MyFile.html {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    include fastcgi_params;
}
1
  • I don't think this will work, as the PHP-FPM default configuration allows only .php scripts to be executed. Solution using rewrite is cleaner IMO. Jun 6, 2014 at 18:40
0

Rename MyFile.html to MyFile.php, and add the following to configuration to the server level:

rewrite ^/path/to/MyFile\.html$ /path/to/MyFile.php last;

This makes an internal redirect in nginx that matches the .html version and redirects to the PHP script for execution. The PHP processing block in your question then processes the request.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .