Skip to content

Instantly share code, notes, and snippets.

@Garconis
Created June 15, 2018 13:05
Show Gist options
  • Save Garconis/cca2347fcc5a122710375f4cee123a8b to your computer and use it in GitHub Desktop.
Save Garconis/cca2347fcc5a122710375f4cee123a8b to your computer and use it in GitHub Desktop.
WordPress | Use htaccess to block logged-out users from certain folders or files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} !wordpress_logged_in [NC]
RewriteRule (^|/)uploads/private/.+?\.(.*)$ login/?redirect_to=/portal/ [R,L]
</IfModule>
@Garconis
Copy link
Author

Note, this will only work on WP Engine, if you have them exclude the path from their caching system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment