Skip to content

Instantly share code, notes, and snippets.

@Garconis
Created February 16, 2018 17:44
Show Gist options
  • Save Garconis/6be796b51994c79010cb0c3a3cfedd86 to your computer and use it in GitHub Desktop.
Save Garconis/6be796b51994c79010cb0c3a3cfedd86 to your computer and use it in GitHub Desktop.
WordPress | NGINX server rule to block access to files in a folder unless logged into WP
set $bar 0;
set $becue 0;
if ( $request_uri ~* "wp-content/uploads/private" ) {
set $bar 1;
}
if ($http_cookie ~ "wordpress_logged_in") {
set $becue 1;
}
set $barbecue "$bar:$becue";
if ($barbecue = "1:0") {
rewrite ^/(.*) https://www.example.com/login/;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment