Want to be here? contact us bar

Do not run PHP scripts on sites or attachment directories under Apache or Nginx

2014.11.22 Server related
  • Article Introduction
  • Upgrade version
  • Comments&Suggestions

If the upload directory is populated with PHP files, it can be executed remotely. For security reasons, we generally prohibit PHP scripts from running in the upload directory.

Under Apache, we can disable running PHP scripts by the following methods:

  1. <Directory /wp-content/uploads>  
  2. php_flag engine off  
  3. </Directory>  

Nginx method is as follows:

  1. location /wp-content/uploads/ {  
  2.  location ~ .*\. (php)?$  {  
  3.  deny all;   
  4.  }  
  5. }  

For multiple directories, they can be restricted together:

  1. location ~* ^/(uploads|images)/.*\. (php|php5)$  
  2. {  
  3. deny all;   
  4. }  
Useful eleven
  • 2014.11.22 It's my first time to meet you!

Waiting for your suggestions on this topic

Comment

Can also input two hundred and forty Characters

Hi, Welcome to join the Wordpress technical exchange group and take you to fly!

I want to join the group
Want to be here? contact us bar
 Wordpress acceleration

I will recommend A more powerful one for you to see?

  • Punk me