• I am creating a very small members only website. I thought the blocking off part of it would be pretty simple as there are many plugins and WordPress has some built in functions.

    However, the one thing I didn’t really think about was that the uploads folder would be hanging out there still with anybody that might have a direct link (even if the chance is low).

    I’ve been researching the htaccess file to achieve this and came across the below. It tested it and it seems work.

    It uses the wordpress logged in cookie to check if they are logged in. Any thoughts on how solid of a solution this is?

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{HTTP_COOKIE} !.*wordpress_logged_in.*$ [NC]
        RewriteCond %{REQUEST_URI} ^(.*?/?)wp-content/uploads/.* [NC]
        RewriteRule . https://%{HTTP_HOST}%1/wp-login.php?redirect_to=%{REQUEST_URI} [L,QSA]
    </IfModule>
    • This topic was modified 3 years, 9 months ago by WPWanderer.
    • This topic was modified 3 years, 9 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Restrict Uploads Folder Via Htaccess…’ is closed to new replies.