How to Stop .htaccess Overwrites

What is your .htaccess file?

Htaccess is short for Hypertext Access and is a configuration file that is used on apache servers. It will control the directory in which it sits and also all subdirectories below it. Not every webhost allows access to edit your .htaccess file however. But if you can configure htaccess files you are able to use those edits to do all of the following:

  • Ban visitors to your site
  • Password protection for folders
  • Create and use customized error pages
  • Define how files with specific extensions are used
  • Redirect visitors

However htaccess security needs to be maintained as even a single letter out of place on this file can crash your site and make it inaccessible. So if you are going to edit htaccess files you should always ensure that you do a full backup of your entire site.
configure htaccess

Problems when you configure htaccess

One of the problems that some users are finding when they want to edit their .htaccess file is that they are having their file rewritten as soon as they have saved it. These overwrites effectively eliminate all of the changes that they have tried to make. The following are some suggestions to eliminate this issue when you configure htaccess:

Putting code in the wrong place when you configure htaccess

One of the common issues if you are new to working with your .htaccess file is putting the information in the incorrect place. All additional code needs to be placed outside of the #Begin and #End. The following shows where you are able to place your code:

[Your code can be placed here]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
[Your code can be placed here]

Conflicts caused by Plugins and Themes within your site

Another issue that often causes issues when you configure htaccess are the theme and the plugins that you are using. To try to diagnose where the issues are arising you should take the following steps:

  • Deactivate all plugins on your installation.
  • If your .htaccess can now be edited successfully you will need to reactivate your plugins one by one until you discover the specific plugin that is causing the issues.
  • Use a default WordPress theme such as Twenty Fifteen and see if the fault goes away; if it does then it your theme that is causing the issues.

edit htaccess

Malware causing your .htaccess to overwrite

Unfortunately another possibility that you may have is that some malicious code has somehow been installed on your directory and is causing the .htaccess file to overwrite. Malware can be installed on your site in many different ways so it is vital that you always:

  • Keep all plugins and themes up to date to avoid any potential routes for someone to get in.
  • Use secure passwords for your site and ensure that no one has access to them.
  • Make regular backups of everything so that you have something that you can revert back to.

Unfortunately what many users find is that if they are attacked my malware and have not managed to maintain a good backup of their site they will have to rebuild the site right from the start unless they are able to seek out and remove the malicious code from all of the many files that there are for their site. Want to stop Google Analytics bots attacks too? Follow our tips or get in touch with our professional team.

If you are still not sure how to fix your htaccess file – ask us for professional help through the comments below!

Request a quote

Attach File

(max file size 5MB; allowed extensions: doc, txt, pdf, docx)

Contact us Request a Quote

Your email address will not be published.

Required fields are marked *

Attach File

(max file size 5MB; allowed extensions: doc, txt, pdf, docx)

subscribe to newsletter

Your email address will not be published.

Required fields are marked *

Ask a Question

Your email address will not be published.

Required fields are marked *

Sorry, this page isn't quite ready yet

redirecting to the old site



cannot account for customer alterations, as the site may reflect changes made after the project was completed.

Mobilunity - Dedicated Developers