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
- How to Deactivate an .Htaccess File
- The Default .Htaccess Code
- How to Reset .Htaccess File Manually
- How to Fix .Htaccess File
- How to Restore .Htaccess File
- What if The .Htaccess File Is Not the Problem
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.
- Login to cPanel.
- Go to File Manager in cPanel.
- Go to the directory containing the WordPress site you are troubleshooting.
- Find the
.htaccess
file. If you can’t see the.htaccess
file, be sure that you are able to view hidden files. - 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.
- 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!
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.
Free Templates Fast & Easy Transfers Free SSL Endless Customization Affordable
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
Hi Innocent,
I recommend contacting Technical Support for direct assistance with this issue.
Best Regards,
Alyssa K.
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
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.