1

I have the following config:

server {
  listen 80 default_server;

  access_log /var/www/logs/access.log;                                                                                           
  error_log /var/www/logs/error.log error;     

  root /var/www/web/;

  index index.html index.php;

  server_name _;

  location / { 
    try_files $uri $uri/ =404;
  }

  # HACK: This is temporary to work around renaming dozens of HTML links
  location ~ \.htm$ {
    root html;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.htm;

    include fastcgi_params;
  }
  # HACK: This is temporary to work around renaming dozens of HTML links

  location ~ [^/]\.php(/|$) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
      return 404;
    }

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;

    include fastcgi_params;
  }
}

And I updated /etc/php5/fpm/pool.d/www.conf adding the line:

security.limit_extensions = .php .html 

Restarted FPM and NGINX but when I access .html files the PHP is not rendered...*.php files execute as expected...

What else am I missing???

Alex.Barylski
  • 2,843
  • 4
  • 45
  • 68
  • I tried commenting out the PHP so it was JUST the html and that didn't work either?!? – Alex.Barylski Apr 22 '16 at 18:34
  • Side note: your regex looks weird: `.+?`. This means "at least one token, which is optional". Either use `.+` (at least one) or `.*` (zero or more). In this specific case of course you should use `.+`, since no file should start with `.php`. – Max Leske Apr 23 '16 at 09:47

1 Answers1

1

I would remove this:

    # HACK: This is temporary to work around renaming dozens of HTML links
  location ~ \.htm$ {
    root html;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.htm;

    include fastcgi_params;
  }

And use this instead:

location ~ \.(php|html|htm)$ {
   root           html;
   fastcgi_pass unix:/var/run/php5-fpm.sock;
   fastcgi_index  index.html;
   fastcgi_param    SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include        fastcgi_params;
}

I hope this solves your issue.

xsultan
  • 191
  • 4