0

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
  • Yeah you need to do some scripting.... Commented Apr 6, 2016 at 19:04

1 Answer 1

0

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.

1
  • thanks that is perfect, i tweaked the script a bit, i am learning bash and should have thought about find Commented Apr 6, 2016 at 19:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.