If you arrived at this article after seeing error 502 or the white screen of death, then you are at the right place. One of the solutions to fix errors like these is to modify your .htaccess file.
This guide will help you locate and reset your .htaccess file to its default configuration.
What is .htaccess file?
The .htaccess file is essentially a WordPress core file. This file reconfigures certain settings of the Apache webserver. You can control specific features of your server with the help of this file. The .htaccess file handles your WordPress security settings and is used to configure password protection and avoid spambots.
The .htaccess file can be found in the root directory after you install WordPress on your webserver. This is, however, a hidden file and can only be accessed when you enable Show Hidden File option.
Before setting off to modify the .htaccess, we recommend you to create a full backup of your WordPress database. Since this tutorial involves accessing your servers file storage system containing important files, you do not want to find yourself dealing with database loss if anything goes wrong.
- Accessing the .htaccess file
The first step you need to do to access .htaccess file is to log in to your server’s control panel or CPanel.
You must use the credentials set by you when you first created your account.
- Open the server’s file manager
In your CPanel, click on the icon named File manager. This will lead you to your WordPress system files.
You will know if it is the right folder if it has folders labelled with wp_.
If you can locate the .htaccess file amongst the other files and folder and skip this following step.
If you were not able to find the file, it must be because of your web host. The .htacess file will be hidden by default. Hence, you will not be able to view it through the file manager.
In this case, the server’s FTP client will be helpful. Open the FTP icon from your control panel. Create a new FTP account. Copy the URL given at the top of your page on to your browser’s address bar. Log in to the page using your FTP details.
- Locating the .htaccess file
Now, you have finally entered your server’s file storage system – either through an FTP client or through your file manager. Look through the various files in the root directory, one of these files should be named .htaccess.
To modify the file, you can just right-click on the file and select the edit option. You can also download and modify offline.
Resetting the .htaccess file to its default configuration
Follow these simple steps to restore the default file
- Copying the current .htaccess file to a different location
If the .htaccess file is malfunctioning, it is better to back up your current file. Even if it is not working at the time being, it may still hold important information about your server.
To create a copy of the file, right-click on the file and select download. Do not forget to rename the old file so that you can find it later.
- Creating a new .htaccess file
Making an empty file, at this point, should be easy enough. Right-click in your file manager or FTP client and select create new file option. Once you are done with it, name your file .htaccess.
Now for the final step, paste the default WordPress .htaccess code into your new file. To do this, right-click on the new file and choose the edit option.
Paste the following code into your new file.
# 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]
</IfModule>
# END WordPress
Finish this up with a click on save and close!
Give yourself a pat on the back because you have successfully restored the .htaccess file to its default configuration!
Through this guide, you have learnt how to restore the .htaccess file to its default configuration. Try it out, good luck!
If you have any further questions, feel free to hit us up in the comments!
Share Your Comments & Feedback