Using Gravity Forms ‘gform_upload_root_htaccess_rules’ PHP filter

The gform_upload_root_htaccess_rules filter allows you to turn off or modify rules being added to the .htaccess file created for the base upload path. It runs daily during the regeneration of the .htaccess file.

Please consult your system administrator before using this filter.


To apply this filter to all forms:

add_filter('gform_upload_root_htaccess_rules', 'my_filter_function');


  • $rules (Mixed): The rules of what to parse or not to parse

More information

See Gravity Forms Docs: gform_upload_root_htaccess_rules


Prevent Gravity Forms from adding default rules to the file

This will only stop Gravity Forms from adding the default rules to the .htaccess file created, after the removal of the existing .htaccess file done daily by the cron task gravityforms_cron

add_filter( 'gform_upload_root_htaccess_rules', '__return_false');

Add new new rules to the .htaccess files

The example below would allow you to add new lines to the .htaccess being regenerated by cron task.

add_filter( 'gform_upload_root_htaccess_rules', function( $rules ) {
    $rules[] = 'a new line in the file';
    $rules[] = 'another new line';
    GFCommon::log_debug( __METHOD__ . '(): .htaccess rules => ' . print_r( $rules, true ) );
    return $rules;
} );


This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in common.php