Put this within server { ... }
block of your vhost
location ~ "^(.*)/your_uploads_folder/(.*)$" {
if (!-e $request_filename) {
return 302 http://yourlivesite.com$request_uri;
}
}
<?php | |
/* | |
* dl-file.php | |
* | |
* Protect uploaded files with login. | |
* | |
* @link http://wordpress.stackexchange.com/questions/37144/protect-wordpress-uploads-if-user-is-not-logged-in | |
* | |
* @author hakre <http://hakre.wordpress.com/> | |
* @license GPL-3.0+ |
#!/bin/bash | |
# | |
# This script configures WordPress file permissions based on recommendations | |
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions | |
# | |
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org> | |
# | |
WP_OWNER=www-data # <-- wordpress owner | |
WP_GROUP=www-data # <-- wordpress group | |
WP_ROOT=$1 # <-- wordpress root directory |
<?php | |
# RegEx For Eval Removal: \s+(eval\(base64.*?\))\); | |
exit; | |
function back_to_for_slash($str) { | |
return str_replace('\\', '/', $str); | |
} | |
$current_dir = back_to_for_slash(dirname(__FILE__) . '/public_html'); | |
$directory = $current_dir; |