Search Results :

×

How to Configure Prevent File Access / Media Restriction for WordPress?

Prevent files/folders access for WordPress provides the easiest way to protect your WordPress files from public users so that your media library can be accessed only by WordPress logged-in users. Your eBooks, PDFs, and other important files can be protected from Google indexing so that data is protected from getting stolen. We support a level of security where you can choose either cookie-based restriction or session-based restriction. Also, we support Apache and Nginx servers to prevent media files. Prevent file/folder access for WordPress is developed to allow you to protect files in your customized way. It will protect files based on their extension.

  • Log into your WordPress instance as an admin.
  • Go to the WordPress Dashboard → Plugins and click on Add New.
  • Search for Prevent file access plugin for WordPress and click on Install Now.
  • Once installed click on Activate.
  • You can also get the plugin from here: Prevent File Access Plugin for WordPress.

Following are the features provided in Prevent file access plugin for WordPress.

Premium Features With Configuration Steps

This feature allows you to restrict the files from the website based on their extension for the website's public users (non-logged-in users).

Follow below steps to configure this feature:

  • Write the file extension in the mentioned field which you want to restrict on your website:
File Restriction - Prevent File Access plugin for WordPress

  • Click Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.

Apache: We need to update the rules in .htaccess file

Nginx: We need to update rules in nginx.config.

If you are looking to restrict only some selected files then you can put them in protected folder and selected files will be protected from public access.

Follow below steps to configure this feature:

  • Go to the Protected Folder tab in the plugin.
  • Click on Choose file → Select the file to restrict from your system → Click on Upload.
Upload files in Protected Folder - Prevent File Access plugin for WordPress

  • The file will be listed in the restricted files list.
Protected Folder files updated successfully - Prevent File Access plugin for WordPress

  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, update the rules in corresponding file.
  • A folder with the name protectedfiles will be created in uploads folder and files in this folder will be restricted from the public user and only logged-in user will be able to access it.
  • You can remove files by clicking on Delete button.

This feature allows you to restrict access to the complete uploads folder or any subfolder in the uploads folder. You can also select multiple folders inside the Uploads folder and they all will be restricted from public access.

Follow below steps to configure this feature:

  • Go to the Folder Restriction tab in the plugin.
  • Click the folders that you want to restrict, you can click on the icon (+) to expand or compress the corresponding folder.
  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.
Folder Restriction tab - Prevent File Access plugin for WordPress

This feature allows you to restrict access to any folder in WordPress instance. You just need to enter the folder name and all the files in that folder will be restricted.

Follow below steps to configure this feature:

  • Go to the Folder Restriction tab in the plugin.
  • Enter the folder name in WP Custom Folder to restrict: field.
WP Custom Folder to restrict - Prevent File Access plugin for WordPress

Note - Media Restriction for WordPress

Note: You can assign multiple folders too, just write folder names separated by comma.


  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.

Whitelist Folder Paths

Use Directly Accessible Media Folders to whitelist specific folder paths so media files in those folders remain publicly accessible without authentication, even when folder restrictions are enabled.

Follow below steps to configure this feature:

  • In the Folder Restriction tab, go to the Directly Accessible Media Folders section.
  • Turn on Enable direct access whitelist using the toggle button.
  • Enter the folder paths in the Whitelisted folder paths: field. Enter one folder path per line (for example, /wp-content/uploads/2026/07).
  • Click the Save Folder Paths button.
Enable Whitelist Folder Paths - Prevent File Access plugin for WordPress

Note - Media Restriction for WordPress

Note: When enabled, media files in the specified folders will be publicly accessible without authentication. Files within these folders will be served directly without authentication checks.


You can use this feature to restrict access to folders based on WordPress roles. Enable role-based restriction and enter the allowed folder name for each role in the ROLE / ALLOWED FOLDER table. Only users with that role (and Administrators) will be able to access the assigned folder.

Follow below steps to configure this feature:

  • In the plugin, click the Folder Restriction tab. Turn on Enable role-based restriction using the toggle button.
  • On enabling, the Role-based Folder Restriction section will open with a ROLE and ALLOWED FOLDER mapping table, as shown in the image below.
  • Enter the folder name in the ALLOWED FOLDER field for each role that should have access to that folder.
Enable Role-based Folder Restriction - Prevent File Access plugin for WordPress

Note - Media Restriction for WordPress

Note: The above settings imply that:


  • Administrator can access all folders by default. Enter a folder name in the Administrator ALLOWED FOLDER field only if you want to restrict that folder exclusively to admins.
  • The additional folder will only be accessed by users with the Editor role (except Administrator).
  • The 06 folder will only be accessed by users with the Author role (except Administrator).
  • Roles with an empty ALLOWED FOLDER field (for example, Contributor and Subscriber) are not assigned a restricted folder.
  • You can also assign multiple folders to a role. Write the folder names separated by a comma. For example, if you want Editor to have access to additional, 06, and uploads, write additional, 06, uploads in the field corresponding to Editor.
  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.

You can use this feature to restrict access to certain folders only to certain users.

Follow below steps to configure this feature:

  • Go to the Folder Restriction tab in the plugin.
  • Click on the toggle button in User base Folder Restriction. On toggling, the User base Folder Restriction section will be enabled.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.
User-Based Folder Restriction - Prevent File Access plugin for WordPress

  • Now go to the Users table in the WordPress admin dashboard and Edit profile of the user whom you want to give access to particular folder.
Users table admin dashboard - Prevent File Access plugin for WordPress

  • Scroll down in the user's profile and you will get a Folder Access section.
Folder Access section in user profile - Prevent File Access plugin for WordPress

  • Enter the folders that can only be accessed by the particular user.
Enter folder data for user - Prevent File Access plugin for WordPress

  • Click on Update User button.

This feature provides multiple redirect options for the file restricted i.e. if the user doesn't have the access to a file then they will be redirected to that particular redirect option.

Follow below steps to configure this feature:

Display Custom Page

  • If user is not allowed to access any file/folder then you can redirect to any page of your WordPress site.
  • Go to the File Restriction tab of the plugin.
  • Under the Redirect Option: section, select Display Custom Page.
  • Under the Redirect to: section, list of all the pages in your WordPress site will be displayed. Select any page where you want to redirect non-logged in user.
  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.
Redirect to Custom Page option - Prevent File Access plugin for WordPress

Redirect to WordPress login

  • This option will redirect a non-logged in user trying to access a restricted file or folder to WordPress login page (wp-login.php).
  • Go to File Restriction tab of plugin.
  • Select Redirect to WordPress login option under Choose Redirect Option:
  • Under Redirect to you will get WordPress login.
  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.
Redirect to WordPress login option - Prevent File Access plugin for WordPress

Redirect to SSO login

  • This option will redirect non-logged in user trying to access restricted file or folder to IDP login page. If you have configured OAuth SSO plugin then user will be redirect to login page of first configured OAuth/OpenID provider, if you have configured SAML SSO plugin then user will be redirected to login page of first configured IDP.
  • Go to File Restriction tab of plugin.
  • Select Redirect to SSO login option under Choose Redirect Option:
  • Under Redirect to option select OAuth SSO login or SAML SSO login based on the SAML/OAuth SSO plugin you're using.
  • Click the Save Settings button.
  • Click on the Show Rules button and select the tab corresponding to your server, you will find the required rules there, and update the rules in the corresponding file.
Redirect to SSO login option - Prevent File Access plugin for WordPress

Provides administrators with granular control over uploaded files, media directories, and user access permissions.

  • Folder & File Level Protection: Restrict access to specific media items, file categories, or entire uploads directories based on user roles or login status.
  • Bulk Media Permissions: Apply security rules across multiple files or folders simultaneously to streamline management.
  • Dynamic Access Control: Enable or disable media protection on-demand without moving files physically on the server.
  • Role-Based Visibility: Specify which user roles (e.g., Administrator, Editor, Subscriber, Custom Roles) can view, stream, or download restricted media files.
  • Media Upload Control: Enable or disable media uploads to control whether users can add new files to the media library.
Folder and file level protection in Media Management - Prevent File Access plugin for WordPress

Role-based visibility and bulk media permissions - Prevent File Access plugin for WordPress

Offers detailed insights and tracking for media consumption, asset usage, and file download activity.

  • Real-Time Access Logs: Track user activity including user ID, IP address, file requested, timestamp, and HTTP response code.
  • Download & View Tracking: Monitor top-accessed files, total download volume, and peak traffic periods.
  • User-Level Insights: View individual user history to audit media usage and identify potential credential or link sharing.
  • Exportable Reports: Generate and export CSV/Excel activity logs for compliance, security auditing, and performance analysis.
Real-time access logs in User Analytics - Prevent File Access plugin for WordPress

Download tracking and exportable reports in User Analytics - Prevent File Access plugin for WordPress

Enforces perimeter network controls to prevent unauthorized access, hotlinking, and web scraping by IP address or range.

  • IP Whitelisting & Blacklisting: Allow or block specific IP addresses or subnets (CIDR ranges) from reaching protected media files.
  • Hotlink & Direct Access Protection: Block external domains and direct URL access unless traffic originates from authorized sources or IP ranges.
  • Geo/Network Policy Enforcement: Safeguard internal assets by restricting file downloads exclusively to corporate networks or specific IP blocks.
  • Automated Threat Mitigation: Temporarily block IP addresses exhibiting suspicious burst access patterns or repeated unauthorized download attempts.
IP Whitelisting and Blacklisting - Prevent File Access plugin for WordPress

Hotlink and Direct Access Protection - Prevent File Access plugin for WordPress

Geo and network policy enforcement for IP restriction - Prevent File Access plugin for WordPress

Free Features With Configuration Steps

Step 1: File Restriction

This feature allows you to restrict the files from the website based on their extension (for eg. doc, pdf, png) for the website's public users (non-logged-in users).

Follow below steps to configure this feature:

  • Write the file extension in the mentioned field which you want to restrict on your website:
File Restriction Free - Prevent File Access plugin for WordPress

  • Click Save Settings button.

Step 2: Protected Folder

If you are looking to restrict some selective files, then you can add them to a protected folder, which will be protected from public access.

Follow below steps to configure this feature:

  • Go to the Private Directory tab in the plugin.
Private Directory Free - Prevent File Access plugin for WordPress

  • Click on Choose file → Select the file to restrict from your system → Click on Upload.
  • The file will be listed in the restricted files list.
Private Directory upload Free - Prevent File Access plugin for WordPress

  • A folder with the name protectedfiles will be created in uploads folder and files in this folder will be restricted from the public user and only logged-in user will be able to access it.
  • You can remove files by clicking on Delete button.

Step 3: Redirection Options

This feature provides multiple redirect options for the file restricted i.e. if the user doesn't have the access to a file then they will be redirected to that particular redirect option.

Follow below steps to configure this feature:

Display Custom Page

  • If user is not allowed to access any file/folder then you can redirect to any page of your WordPress site.
  • Go to the Select Server & Redirect option tab of the plugin.
Display Custom Page Free - Prevent File Access plugin for WordPress

  • Under the Redirect Option: section, select Display Custom Page.
  • Under the Redirect to: section, list of all the pages in your WordPress site will be displayed. Select any page where you want to redirect non-logged in user.
  • Click the Save Settings button.

Redirect to WordPress login [Available in Premium version]

  • This option will redirect a non-logged in user trying to access a restricted file or folder to WordPress login page (wp-login.php).
  • Go to Select Server & Redirect option tab of plugin.
Redirect to WordPress login Free - Prevent File Access plugin for WordPress

  • Select Redirect to WordPress login option under Choose Redirect Option:
  • Under Redirect to you will get WordPress login.
  • Click the Save Settings button.

Redirect to SSO login [Available in Enterprise version]

  • This option will redirect non-logged in user trying to access restricted file or folder to IDP login page. If you have configured OAuth SSO plugin then user will be redirect to login page of first configured OAuth/OpenID provider, if you have configured SAML SSO plugin then user will be redirected to login page of first configured IDP.
  • Go to Select Server & Redirect option tab of plugin.
Redirect to SSO login Free - Prevent File Access plugin for WordPress

  • Select Redirect to SSO login option under Choose Redirect Option:
  • Under Redirect to option select OAuth SSO login or SAML SSO login based on the SAML/OAuth SSO plugin you're using.
  • Click the Save Settings button.

Step 4: Security Level Base

This feature determines how you want to check whether the user is logged in or not. There are two options available:

  • Cookie: This will check whether the user is logged in or not based on the login cookie in the browser. This method is less secured comparative to session based security level.
  • Session [Available in Enterprise version]: This will check whether the user is logged in or not based on the active session of the user in the WordPress site server. This is the most secured method.

You can follow the below steps to setup the desired Security level base on your WordPress site:

  • Go to Select Server & Redirect option tab of plugin.
Security Level Base Free - Prevent File Access plugin for WordPress

  • Under Security Level Base:, select Cookie option.
  • Click the Save Settings button.

Server Selection

Make sure you have selected the correct server on which your website is running. Please refer to the following image.

Note - Media Restriction for WordPress

Note: In the free version we only provide demo rules for NGINX, full extension of NGINX server rules will be available in premium or Higher versions of plugin.


Server Selection Free - Prevent File Access plugin for WordPress

Note - Media Restriction for WordPress

Note: For some hosting provider, you might need to communicate with the hosting provider support to update the rules in nginx.config. Please make sure that your hosting provider is ready to upload the rules. Same is valid for all the plugin features.



In this guide, you have successfully configured the Prevent File Access / Media Restriction plugin for WordPress. You can now protect files and folders from public access, apply role or user-based restrictions, set redirect options, manage media permissions, review user analytics, and restrict access by IP for your media library.




 Thank you for your response. We will get back to you soon.

Something went wrong. Please submit your query again

We'll Reach Out to You at the Earliest!



ADFS_sso ×
Hello there!

Need Help? We are right here!

support