I am having some odd traffic to the xmlrpc.php files hosted by the wordpress sites on my server. Instead of opening each htaccess file to add a deny rule, is there an easy way to echo or insert the line into all htaccess files in the www directory?
1 Answer
Put this into a file at root of all your vhosts and name the file htaccess_ins_deny_xmlrpc
<Files "xmlrpc.php"> Order Allow,Deny deny from all </Files> Now, alongside that file, create a bash script:
for htfile in `find . -name .htaccess` do cp "$htfile" "$htfile.bak" cat "htaccess_ins_deny_xmlrpc" >> "$htfile" done This will check all vhosts for the .htaccess file. If the .htaccess file is found, this will make a backup and append the rule.
- thanks that is perfect, i tweaked the script a bit, i am learning bash and should have thought about findn3rd– n3rd2016-04-06 19:54:00 +00:00Commented Apr 6, 2016 at 19:54