Htaccess changes itself

My htaccess file get change automatically. After few days my site becomes inaccessible with www. When I check htaccess, its empty. I put the code again to direct www to non-www. After few days it changes again. Is some virus causing this?

Have a look through any log files, is there any entries that look suspicious?

Run an anti-virus scan and malware/spyware scan (inc your own computer) in case you have any virus and/or malware.

If the scans come up clean, change your FTP password in case someone has gotten their hands on your FTP password


.htaccess is not self-updating and should never be accessible by a visitor to your website. Therefore SP’s advice is good (especially about your password).

Start by asking your host whether they’re responsible for this anomaly.

That said, it is possible for YOU to create a script to update your .htaccess file to ban visitors by IP address, etc., via PHP. This, however, is not for the timid as any error introduced by a change can bring your website down.



its either there are automated programs running on it, or could be compromised

Thanks for your advices, mates.