.htaccess code

If you have inadvertently deleted the .htaccess code in the dlm_uploads folder, it’s essential to re-add it to maintain the security and proper functioning of your web server. Below is the code that should be placed in the .htaccess file:

# Apache 2.4 and up
<IfModule mod_authz_core.c>
Require all denied

# Apache 2.3 and down
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all

This .htaccess code is designed to protect the contents of the dlm_uploads directory by denying access to unauthorized users. The code works seamlessly with both Apache 2.4 and later, as well as Apache 2.3 and earlier versions.

Additionally, if your server is running on Nginx, add the following rules to your Nginx configuration file:

location /wp-content/uploads/dlm_uploads {
    deny all;
    return 403;

This Nginx configuration is necessary to disable direct file access and enhance the security of your downloads.

Explanation of the Code

  • In Apache 2.4 and newer versions, it uses the mod_authz_core module to deny access to all users. This effectively blocks access to the contents of the folder, ensuring that only authorized requests are permitted.
  • In Apache 2.3 and earlier, when the mod_authz_core module is not available, the code utilizes the Order, Allow, and Deny directives to achieve the same result. It orders the server to first “Allow” and then “Deny” access to all, effectively denying access to everyone.
  • For Nginx, the added configuration denies all access and returns a 403 Forbidden response for the specified location.

By implementing both the .htaccess code for Apache and the Nginx configuration rules, you ensure comprehensive protection for your dlm_uploads directory, regardless of the web server being used.

Make sure to save the appropriate code in the relevant configuration file (either .htaccess or Nginx configuration), and if you encounter any issues or have further questions about securing your website, please reach out to your server administrator or hosting provider for assistance.

Was this article helpful?

Related Articles

Start Protecting your WordPress Downloads

Protect and track downloads on WordPress... What are you waiting for?