Media File Restriction Just Doesn’t Work
-
Before I get into the issue I’m attempting to address I do have to say that the support page that people keep getting told to visit doesn’t actually offer any support avenues. The contact form on the AAM site explicitly states that support questions shouldn’t be submitted there and then sends you back to the same support page that doesn’t give any options for support. There’s some FAQs and the Knowledge Base, but what does one do if following a Knowledge Base article is what has resulted in the need for support?
That said:
https://aamplugin.com/article/how-to-manage-access-to-the-wordpress-media-library
Followed the procedure for NGINX servers and configured AAM as instructed.
Initially, this broke the site as other plugins were writing custom CSS to files in uploads (MegaMenu) and those files became inaccessible.
All images, assets, etc. were unable to load not just for anonymous visitors, but for all users, regardless of how we configured AAM’s global rules. We wanted to restricted media file access to all anonymous users, but grant access to all ‘logged in users’.
What we got was either ‘everything is restricted for everyone all the time and the site breaks’ or ‘nothing is ever restricted at all’.
What we’re after, or rather what we’ve settled on, is restricting access to PDFs, MP3s, MP4s, MOVs, XLSX and XLS files. We have re-applied the NGINX configuration but narrowed the scope of what is being restricted. We have configured the global settings and then attempted to restrict individual media files (of the types listed above) for anonymous users.
Unfortunately, anonymous users can still access the files directly.
What do we need to do to make this all work?
This is the NGINX configuration:
location ~* /wp-content/uploads/ { rewrite (?i)/wp-content/uploads/.pdf$ /index.php?aam-media=$1 last; rewrite (?i)/wp-content/uploads/.mp3$ /index.php?aam-media=$1 last; rewrite (?i)/wp-content/uploads/.mov$ /index.php?aam-media=$1 last; rewrite (?i)/wp-content/uploads/.mp4$ /index.php?aam-media=$1 last; rewrite (?i)/wp-content/uploads/.xlsx$ /index.php?aam-media=$1 last; rewrite (?i)/wp-content/uploads/.xls$ /index.php?aam-media=$1 last; }
- The topic ‘Media File Restriction Just Doesn’t Work’ is closed to new replies.