Blueprints · WordPress
Beginner
10 min · Nginx
Deny PHP in WordPress uploads
Stages a location that refuses to execute PHP under wp-content/uploads.
Live config
Baked-in protections
- Uploads are not executed as PHP
- The snippet is staged
- Nginx is not reloaded
Step 1 · conf
Uploads location
/root/portgate-blueprints/deny-uploads-php.conf
Include this in the WordPress server block.
location ~* /wp-content/uploads/.*\.php$ {
deny all;
}
Step 2 · bash
Read-only check
/root/portgate-blueprints/uploads-php-check.sh
Prints status. It does not change the service.
#!/bin/sh set -eu find "/var/www/html/wp-content/uploads" -name '*.php' 2>/dev/null | head || echo "No PHP files found in uploads, or the directory is missing."