PDA Status & Rewrite Rules

Rewrite rules play an indispensable role in how our PDA works. That’s why you should implement them correctly in order for our plugin to work properly.

Rewrite Rules

Our PDA Gold officially supports Apache, IIS (Windows) and NGINX servers at the moment.

While our rewrite rules are inserted automatically for Apache servers, you have to implement these rules manually for multisite networks, IIS (Windows) and NGINX servers.

Sometimes, our plugin won’t be able to detect which server is actually serving your static files. You have to contact your hosting provider to get the actual server and implement the correct rewrite rules accordingly.

If you get stuck at the our “Helpers” screen, please follow these simple steps:

  1. Double-check if our rewrite rules are inserted correctly
  2. Choose the “Use Raw URLs” option first
  3. When our settings page shows up, turn off “Keep Raw URLs” option
  4. Protect a file with our PDA Gold and double-check if its file access permission runs correctly

WordPress .htaccess and Sample PDA Gold Rewrite Rules

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Prevent Direct Access Rewrite Rules
RewriteRule ^private/([a-zA-Z0-9-_.]+)$ index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy [L]
RewriteRule ^wp-content/uploads(/_pda/.*\.\w+)$ index.php?pda_v3_pf=$1 [QSA,L]
# Prevent Direct Access Rewrite Rules End

# IP Block Rewrite Rules for Folder Protection
RewriteRule ^wp-content/uploads(/(paid-members)/.*\.\w+)$ index.php?pda_v3_pf=$1 [QSA,L]
# IP Block Rewrite Rules for Folder Protection End

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Force Local Rewrite Rules

Our custom rewrite rules are added in the .htaccess file under the root folder, which is the same place as WordPress rules by default. However, since other plugins also implement their rules there, it might cause some conflicts that make our function not work properly.

If our PDA Gold doesn’t work as expected even though the rewrite rules are inserted correctly in the .htaccess file, please create a .htaccess rewrite rules under the _pda folder instead.

To do so, simply follow the steps below:

  1. Navigate to Prevent Direct Access Gold >> Settings from your admin dashboard
  2. Turn on the “Enable Debug Logs” option
  3. Then enable the “Force Local Rewrite Rules” option

PDA Status

When enabling debug logs, you can also see the PDA Status under Helpers tab. This helps you check if our plugin is working as expected at a particular time.

Here are the 4 PDA statuses that you might encounter:

  • Our plugin is up and running

 The plugin is working as expected.

  • Our plugin is working with some limitations

You are using raw URLs but haven’t blocked access to our _pda folder yet.

When you enable raw URLs, our plugin will block the _pda folder for you automatically. However, sometimes it cannot be done due to missing file permission.

Learn how to block access to our _pda folder manually.

  • Our plugin isn’t working properly due to incorrect Raw URLs setup

Our plugin has failed to remove our .htaccess file from the _pda folder, which should be done when you disable the Raw URLs option.

Please delete the file manually for our function to work properly.

  • Our plugin isn’t working due to incorrect rewrite rules

Our rewrite rules are not implemented correctly.

Please double check our guidance right below the PDA Status section or try to insert rewrite rules under the _pda folder instead.

Our “status” helper is by no way perfect. There are cases, especially on Nginx servers, where our rewrite rules are not implemented on a usual config file. As a result, our helper would fail to detect the correct rules.

Raw URLs Limitations

Our Raw URLs comes in useful when you’re using WordPress.com or NGINX servers that don’t allow modifying rewrite rules. However, it comes with some limitations:

  • Those who could somehow get the original file URL will be able to access your private files directly
    https://preventdirectaccess.com/wp-content/uploads/_pda/2019/04/ToDo-List.pdf
  • Our Robots meta tag and X-Robots-Tag HTTP header to block search indexing will no longer be working

What’s still working:

  • Your File URLs still follow our File Access Permission
  • Robots.txt rules are still in place to stop Google and search engines from crawling your private files

In order to overcome these limitations, you have to block access to our _pda folder.

How to block access to “_pda” folder

Once the Raw URLs option is enabled, you have to block access (all requests) to our private _pda folder for PDA Gold to work thoroughly. There are 2 ways to do so:

  1. Put the following .htaccess rules under wp-content/uploads/_pda folder for Apache and NGINX servers that support .htaccess like Cloudways
    Order deny, allow
    Deny from all

    Once our Raw URLs option is OFF, you should remove the .htaccess file under our _pda folder. Our plugin will do this automatically for Apache servers. In case it somehow fails, you may want to remove it manually.

  2. Implement our rewrite rules for NGINX instead of using Raw URLs in the first place.
Lasted updated on February 22, 2021