How to make Prevent Direct Access work on WP Engine

By default, our plugin (both Free and Gold version) doesn’t work on websites hosted on WP Engine who utilizes both Apache and Nginx web server.

However, with these simple tweaks now you can use Prevent Direct Access plugin on WP Engine:

  1. Login to your WP Engine User Portal
  2. Under your website “Installs”, click on “Redirect rules” then “New redirect rule”

  3. Enter these codes into the popup fields as per our attached screenshot
    Domain: Choose your website domain
    You will need to create 2 redirect rules as described below.

    For version 3.0 and above

    Redirect name: Rules for original links
    Source: wp-content/uploads(/_pda/.*\.\w+)$
    Destination: https://www.yourwebsite.com/index.php?pda_v3_pf=$1
    Redirect type* 301 Permanent

    Redirect name: Rules for private links
    Source: private/([a-zA-Z0-9-_]+)$
    Destination: https://www.yourwebsite.com/index.php?pda_v3_pf=$1&pdav3_rexypo=ymerexy
    Redirect type* 301 Permanent

    * Please follow your WordPress Site Address (URL) – with or without www

    Rules for original links
    Redirect Rules for Prevent Direct Access original links
    Redirect Rules for Prevent Direct Access private links

    For version 2.x.x

    Redirect name: Rules for original links:
    Source: wp-content/uploads/(.+)(\.)([A-Za-z0-9]+)$
    Destination: index.php?pre_dir_acc_61co625547=$1&is_direct_access=true&file_type=$3
    Redirect type* 301 Permanent

    Redirect name: Rules for private link:
    Source: private/([a-zA-Z0-9-_]+)(/auth-[a-zA-Z0-9-_]+){0,1}$
    Destination: index.php?pre_dir_acc_61co625547=$1&custom_181191=$2
    Redirect type* 301 Permanent


Please note that:

  • If you change Prefix for Private URL (on our Settings page), you need to replace the word private accordingly
  • If you’re having trouble setting up these redirect rules on WP Engine, you can just enable this “Keep raw private & original file URLs” settings option for our plugin to be up and running immediately.

    As a matter of fact, using raw file URLs will speed up “readfile” process as the requests don’t have to go through htaccess and redirect rules anymore. On the minus side, you cannot use pretty permalinks and raw URLs doesn’t look as nice.
  • As WP Engine doesn’t support RewriteRule Flags, all your private and original links will appear raw anyway. However, if you implement these WP Engine redirect rules, you can use (and access) pretty as opposed to raw URLs. For example,
    • Raw (Ugly) URL: http://bwps.com/index.php?pda_v3_pf=/_pda/2018/09/ava-2.png
    • Pretty URL: http://bwps.com/wp-content/uploads/_pda/2018/09/ava-2.png
  • As always, please make sure you’re using the latest version of our plugin.

Feel free to contact us for support if you face any problems or have any questions.

Lasted updated on November 5, 2018