Last active
June 20, 2022 15:37
-
-
Save ianpegg/3c89a976eb94cb7e4b29f474453a87dc to your computer and use it in GitHub Desktop.
WP Uploads directory .htaccess configuration: prevent code execution and load files from LIVE when in DEV environments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## Uploads directory .htaccess configuration ################# | |
## Prevent code execution and load files from LIVE when in DEV environments ## | |
# BEGIN Uploads directory code execution protection | |
<IfModule mod_php5.c> | |
php_flag engine 0 | |
</IfModule> | |
<IfModule mod_php7.c> | |
php_flag engine 0 | |
</IfModule> | |
<IfModule mod_php.c> | |
php_flag engine 0 | |
</IfModule> | |
AddHandler cgi-script .php .phtml .php3 .pl .py .jsp .asp .htm .shtml .sh .cgi | |
Options -ExecCGI | |
# END Uploads directory code execution protection | |
# Attempt to load files from production if they're not in our local version | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule (.*) https://example.com/wp-content/uploads/$1 [NC,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment