Replace Unprotected URLs In Your Content

Once a file is protected by Prevent Direct Access (PDA) Gold, its URL is actually changed as we move the file into our protected folder, i.e. _pda. So if you protect a media file that is already embedded in your content, that image or document (URL) will go missing.

What you can do is simply updating the unprotected with protected URLs manually in your content. That works if there are only a few protected files on your content. What if there are hundreds of these files?

That’s when our recently released settings option comes in useful.

Once, the settings option is enabled, our PDA Gold will:

  • Filter the content of your WordPress page or post after it’s retrieved from the database and before it’s displayed to the screen using the_content filter
  • Search for all the <img> and <a> tag in the content using regular expressions
  • Once we have all the file URL of images and links embedded in the content, we will check if the URL exists in the database (DB):
    •  If it does, the file is not protected and we leave it as it is
    •  If it doesn’t, we insert the _pda into the URL and check again whether it exists in the DB. If it does – meaning the file is protected, we will update its file URL accordingly.

By using WordPress the_content filter, our Gold version will do the URL replacement automatically for you. In other words, you don’t have to manually update the protected file URL in your content anymore. This method is arguably better than replacing the actually file URLs in the DB which require you to do the reverse process when unprotecting the files.

On the minus side, there will be a slight delay on every page load. That’s why you have to select which pages you want our plugin to filter and replace the unprotected URLs after enabling the option. If we filter content of all your pages and posts, it will definitely affect the load speed of these pages and your website at large.

Using the_content filter Replacing the actual file URL in the DB
Process Run and update the file URL dynamically on page load Run a heavy SQL searching, checking and replacing the file URL of all your attachment files
Frequency On every page load Once
Effectiveness Run on selected pages only Have to search and replace the file URL again once the file is unprotected

This is also how our magic links work as well.

In short,

  • If there are only a few unprotected file URLs in your content, just manually update them with the protected ones
  • If there are hundreds of them, enable our settings option above and select which page(s) our PDA Gold should find and change file URLs automatically for you
Lasted updated on October 1, 2018