Solve Nginx+PHP-FPM Access Denied Issue

Recently one of our services went down due to an Apache upgrade that caused Htaccess to have contents that are no longer supported. When we go to our app, it throws out an “Access Denied” error. Our developers looked into all sorts of possible scenarios including

  1. IonCube Issues
  2. File Permission Issues
  3. Owner/User Group Issues
  4. Directory Index Issue

After a quick research, a lot of people who experienced issues with this suggested solution that involves modifying the PHP-FPM configuration file. Apparently, if the security.limit_extensions directive is set to specific file types, it won’t parse PHP in other file types causing an error such as “Access Denied”.

So we set the security.limit_extensions directive to parse .html files as well and restarted the PHP-FPM. Unfortunately, this didn’t solve the problem for us. We had to modify our Htaccess file to contain a “?” which fixed the syntax issue and thereby fixing the issue we were facing with “Access Denied” page.

Here’s how we did it…

Our original Htaccess File Contents:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond $1 !^(index\.php|images|robots\.txt)
  RewriteRule ^(.*)$ ./index.php/$1 [L]

This worked fine until the Apache was upgraded. This following RewriteRule syntax is no longer supported.

RewriteRule ^(.*)$ ./index.php/$1 [L]

The corrected RewriteRule is:

RewriteRule ^(.*)$ ./index.php?/$1 [L]

The difference is in the “?” mark after the index.php

That fixed the issue for us. After upgrading the Apache, it is always good to check if all the sites are working and if your Htaccess file contains correct syntax. Hope it helps someone out there having similar issues.