Configure NGINX Rules to Protect Files on Bedrock Setup

Here’s how to configure Nginx configuration file for our PDA Gold to work correctly on Bedrock‘s setup & structure.

Step 1: Locate your server block configuration file.

Step 2: Put the following rewrite rules inside the server block.

server {

  listen 80;
  server_name example.com;

  root /srv/www/example.com/web;
  index index.php index.htm index.html;

  # Prevent PHP scripts from being executed inside the uploads folder.
  location ~* /app/uploads/.*.php$ {
    deny all;
  }

  location ~* /bedrock/web/app/uploads/_pda {
       rewrite uploads(/_pda/.*\.\w+)$ "/bedrock/web/index.php?pda_v3_pf=$1" last;
   }
   location ~* /bedrock/web/private {
        rewrite private/([a-zA-Z0-9-_]+)$ "/bedrock/web/index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy" last;
   }
}

Step 3: Restart your Nginx server.

Step 4: Go back to our PDA Gold settings page. Click on “Check rewrite rules” button.

In case you’re using Apache server with Bedrock setup, simply put our Gold rewrite rules on .htaccess file usually located at web/.htaccess.

That’s all you have to do. Now our file protection should be working correctly on your website hosted on Bedrock.

Lasted updated on December 15, 2021