• Resolved glyndavidson

    (@glyndavidson)


    Is it possible to give an example of how to filter the htaccess rules?

    I tried this in an MU plugin but it doesn’t work 🙁

    add_filter('aiowps_htaccess_rules_before_writing', 'change_htaccess_rules');
    function change_htaccess_rules($rulesarray){
    	foreach($rulesarray as $rule){
    		str_replace('Options All -Indexes', 'Options -Indexes', $rule);
    	}
    	return $rulesarray;
    }

    https://wordpress.org/plugins/all-in-one-wp-security-and-firewall/

Viewing 1 replies (of 1 total)
  • Plugin Contributor wpsolutions

    (@wpsolutions)

    Hi @glyndavidson,
    The reason your code isn’t working is because you aren’t modifying the original “$rulesarray”.

    Here’s an alternative and faster way you can try by using json_encode/decode:

    function change_htaccess_rules($rulesarray){
    return json_decode(str_replace('Options All -Indexes', 'Options -Indexes',  json_encode($rulesarray)));
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Filtering htaccess rules’ is closed to new replies.