Modifying EDD .htaccess file rules
Easy Digital Downloads uses a .htaccess file (for Apache servers) to protect product download files. This file is placed in wp-content/uploads/edd/. The rules in the file will differ depending on your Download Method set in Downloads → Settings → Misc.
If Download Method is set to Forced, the default .htaccess rules are:
Options -Indexes deny from all
If Download Method is set to Redirect, the rules are:Options -Indexes
How to modify .htacess rules
Below are different options on modifying the .htaccess rules, either via a filter or using a WordPress plugin.
Note: EDD rewrites the .htaccess once a day so you cannot make changes directly to the .htaccess file itself, otherwise those changes will get overwritten.
1. Update rules using a the edd_protected_directory_htaccess_rules filter:
These rules can be changed using the edd_protected_directory_htaccess_rules filter. For example, if you want to block direct access to .mp3 files (by default they are allowed), you can use this:\n"; $rules .= "Order Allow,Deny\n"; $rules .= "Allow from all\n"; $rules .= "\n"; break; endswitch; return $rules; } add_filter( 'edd_protected_directory_htaccess_rules', 'edd_custom_modify_htaccess_rules', 10, 2 );
In order for the changes to take affect, go to Downloads → Settings → Misc and click “Save Changes”.
2. Modify .htaccess via plugin
You can also use the free EDD .htacces Editor extension to modify these rules without touching any PHP.
If you need to get rid of everything, includingOptions -Indexes
then you can use a function similar to above, but with nothing in it. Example: