• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Prevent PHP-FPM to execute .php? files

Pascal_Netenvie

Regular Pleskian
Server operating system version
Debian 11.7
Plesk version and microupdate number
18.0.52
Hi,
For security reasons i want to prevent PHP-FPM to execute file with extension php3|php4|php5|php7|php8 etc ...
Actually these files are executed.
How can i disable this please ?
 
In a one-liner in .htaccess for example:
RewriteRule ^your-directory/.*\.(php3|php4|php5|php7|php8)$ - [F,L,NC]
With your-directory = the start path to the files, this can also be just /.* or .*
 
Ok but there is no way to put this rule in apache server configuration ?
I have my own configuration file in /etc/apache2/conf-enabled/ and i added following lines in it but it seems to not work :

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule \.(php3|php4|php5|php7|php8)$ - [F,L,NC]
</IfModule>
 
Ok finally i used this and it work perfect :

Code:
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch "\.(php3|php4|php5|php7|php8)$">
Require all denied
</FilesMatch>
</IfModule>
</IfModule>
 
And finally i changed it to :


Code:
<IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    <FilesMatch "\.(php.)$">
      Require all denied
    </FilesMatch>
  </IfModule>
</IfModule>
 
Back
Top