Protected media files on NGINX

Introduction

Since version 7.X, LifterLMS can protect certain media files from public access, such as images uploaded as part of a quiz. This is automatic via an .htaccess file. If your web hosting is not running Apache however this won’t work.

In order to protect these files on a web server running NGINX, you will need to create a configuration to prevent direct access to the files.

Protecting Files on WPEngine

  1. Once logged in to your WPEngine account, under Sites, select your site
  2. Click on “Redirect Rules” in the menu on the left, then click the “Add redirect rule” button
  3. Enter a description for the rule under “Redirect name”, enter / under Destination, and enter the following under Source:

^/wp-content/uploads/lifterlms/

Your rule should look something like the following:

Click “Add redirect rule” to add the rule.

Protecting Files with Other Web Hosts

Your web hosting provider should be able to direct you on how to create a redirect for the /wp-content/uploads/lifterlms/ folder.

A manual configuration rule would look something like this:

location ~ ^/wp-content/uploads/lifterlms/(.*)$ { return 301 /; }

Be sure to test that you are not able to access any files in that folder directly.

Last Updated on
Was this article helpful?