How to Reset .Htaccess File

how to reset htaccess file title image

Knowing how to reset .htaccess files on your server can save you lots of time. An .htaccess file is a configuration file Apache servers use to configure page loading and redirects. WordPress requires a specially configured .htaccess file to run, but many themes and plugins will edit the WordPress .htaccess file and may conflict with each other. The easiest way to resolve the situation is to reset the file and troubleshoot from there.

Why Reset .Htaccess

Why would you bother resetting your WordPress .htaccess file? Let’s illustrate the reason with an example scenario — while installing a theme or plugin on your WordPress site, you encounter a confusing error message. According to the error, your PHP version is out of date. When you check your PHP version in cPanel’s MultiPHP Manager, it looks like you’re using the latest available! This sort of issue is just the kind of problem caused by a coding error in the site’s .htaccess file. Let’s take a look at how to resolve this WordPress PHP error.

Note: While some people simply type htaccess when discussing the file, the file is more properly called the .htaccess file. ‘Dot’ files are, by default, hidden from view, but visible after you adjust certain settings. The ‘dot’ is necessary for the file to work properly — the server won’t recognize the file without it!

How to Deactivate an .Htaccess File

Keep in mind that, removing or deactivating the WordPress .htaccess file will briefly cause your site to go down. Setting your .htaccess back to the default can affect some plugins. If able, you may want to restrict access to your site while you troubleshoot. With that out of the way, let’s head to cPanel’s File Manager and deactivate that troublesome .htaccess file.

  1. Login to cPanel.
  2. Go to File Manager in cPanel.
    cPanel File Manager Icon
  3. Go to the directory containing the WordPress site you are troubleshooting.
  4. Find the .htaccess file. If you can’t see the .htaccess file, be sure that you are able to view hidden files.
    Sample WordPress Directory with .htaccess file highlighted
  5. We aren’t going to delete the file— instead we will rename it. That way you will still have it for reference if you need to reconfigure a plugin or theme! Right-click on the file and select Rename.
    Right Click Menu in File Manager to Rename
  6. You can deactivate the file by simply adding an extension that cPanel won’t recognize to the end. .bak is a popular choice in cPanel and Apache since it reminds the user that the file is a backup. I’d also suggest adding the current date to the end of your renamed file. This makes things much easier if you ever have to go through the files later. You’ll have a hard time remembering the difference between .htaccess1.bak and .htaccess2.bak, but will easily be able to tell .htaccess03042019.bak and .htaccess09082019.bak apart!
    renamed .htaccess file

With the .htaccess file deactivated, you can reset the file manually or troubleshoot the problem file.

For tips on using the File Manager for a variety of tasks, take a look at our guide to using File Manager in cPanel!

The Default .Htaccess Code

This is the default content in a WordPress .htaccess file. We’ll be referring to it in the tips below, so be sure to copy it whenever you need to overwrite or fill-in a new file.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

How to Reset .Htaccess File Manually

Since you’ve already deactivated the old WordPress .htaccess file, you can use File Manager to create a new file named .htaccess. Simply edit this newly created file, paste in the default code from above, and you’ve now regenerated your .htaccess file. When you do this, you should be able to access your WordPress site, but any custom plugins that edit the .htaccess file to work will not be working. Don’t worry, we’ll cover how to fix this below.

How to Fix .Htaccess File

If you were trying to update WordPress or a plugin, you should be able to do so now. Once everything is up to date, you’ll probably want to deactivate and reactivate your plugins one by one. Many plugins add code to the .htaccess file as part of their installation— reactivating the plugins should put any necessary code back in the .htaccess file. Do this one at a time so that you’ll be able to tell if one plugin in particular causes an error.

For simpler sites, plugin reactivation should be more than enough. If you’re using plugins that put a great deal of custom code in the .htaccess file, you may need to open the old version of the .htaccess in cPanel’s file manager and copy the relevant code over to your new .htaccess.

If you went through all of those steps, only for the problem to repeat itself, you need to narrow down what plugin or plugins causes the issue. As you reactivate plugins, only reactivate one at a time. Wait a bit between each one and see if a certain plugin causes your site to experience the same problem you were originally troubleshooting.

Is this a bit of a pain? Yes, definitely! But, it’s the simplest and most direct way to figure out what the problem plugin is. Once you narrow it down, you can decide if you want to replace the plugin, update the plugin, simply deactivate it, or reach out to the plugin developer for further troubleshooting.

How to Restore .Htaccess File

If you ever need to restore an old version of the WordPress .htaccess file that you saved, simply deactivate the current .htaccess file, and rename the old, archived file back to .htaccess.

What if The .Htaccess File Is Not the Problem

If setting your WordPress site’s .htaccess to a default file did not resolve the issue, you will need to check some other files. Try troubleshooting your site’s php.ini file and the wp-config.php file. These files can also contain code that overrides your PHP settings. As always, make backup copies of each before you delete anything!

Build a WordPress site fast with a hosting plan that includes a visual drag-and-drop website builder, free domain, and hundreds of design templates.

check markFree Templates check markFast & Easy Transfers check markFree SSL check markEndless Customization check markAffordable

WordPress Website Builder

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

4 thoughts on “How to Reset .Htaccess File

  1. How can I use htaccess file to rewrite this address without error /index.php?p=blogs/viewstory/181 it my social media network site called pclasp I have tried all I could but is not working out each time I add the rewrite code into htaccess file I can’t login again as an admin why I need help please

    1. Hi Innocent,

      I recommend contacting Technical Support for direct assistance with this issue.

      Best Regards,
      Alyssa K.

  2. What if is not an wordpress site what else will I do because my invitation is not working in my website where people click to invite their friends

    1. Hello Innocent,

      Thank you for your question. I recommend contacting a developer that is experienced in whatever software you are using to build your site.

      Best Regards,
      Alyssa K.

Was this article helpful? Join the conversation!