NGINX Support

Prevent Direct Access Gold now supports Nginx, together with the most popular Apache server. Since Nginx does not have .htaccess-type capability, Prevent Direct Access Gold and WordPress at large cannot modify and update the server configuration automatically for you.

There are 2 ways to make our Prevent Direct Access Gold (PDA) work perfectly with Nginx webservers:

Please follow our instructions for these specific hosting providers and platforms:

Implement Our Nginx Rewrite Rules Manually

This is a recommended method to keep pretty permalinks for your file URLs.

For Prevent Direct Access Gold version 3.0 and above

  1. Copy the rewrite rules shown on Prevent Direct Access Gold Settings page
  2. Find and open your website’s Nginx config file which is normally located at /etc/nginx/site-available (or /etc/nginx/conf/site-available if you’re using Arch Linux)
  3. Put it inside the server block
    server {
    
        location / {
         ...
        }
    
       #Put our rewrite rules here, i.e.
       rewrite wp-content/uploads(/_pda/.*\.\w+)$ "/index.php?pda_v3_pf=$1" last;
       rewrite private/([a-zA-Z0-9-_]+)$ "/index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy" last;
    }

    If your WordPress installation is under a subdirectory, you should update them accordingly.

    rewrite subdirectory/wp-content/uploads(/_pda/.*\.\w+)$ "/subdirectory/index.php?pda_v3_pf=$1" last; 
    rewrite subdirectory/private/([a-zA-Z0-9-_]+)$ "/subdirectory/index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy" last;
  4. Restart your Nginx server. Our Prevent Direct Access Gold should be now working on your website.

For version 2.0 and below

Please use this rewrite rules instead:

server {

    location / {
     ...
    }

   #Put our rewrite rules here, i.e.
   rewrite wp-content/uploads/(.+)(\.)([A-Za-z0-9]+)$ "/index.php?pre_dir_acc_61co625547=$1&is_direct_access=true&file_type=$3" last;
   rewrite private/([a-zA-Z0-9-_]+)$ "/index.php?pre_dir_acc_61co625547=$1&custom_181191=$2" last;

}

Use Raw URLs

For those hostings that don’t allow rewrite rules modifications, you should consider using our Raw URLs with these limitations.

For Nginx servers that also support .htaccess such as Flywheel and Cloudways, you can block access to our “_pda” folder to overcome those limitations.

Lasted updated on August 23, 2021