.htaccess is one of the most important files on your WordPress installation. A file that can make your website go down with a single mismatched configuration or invalid letter in it. So, you should be very careful while playing with the .htaccess file or making changes to it. It doesn’t mean that you shouldn’t touch the file. It is necessary to make changes to .htaccess to protect your website, block IPs, speed it up, and do a couple of other things. So, leaving it as it is may not be possible in every scenario.
In this article, we are going to give you the default .htaccess file which you can use in case you made any mistakes and your website is no more running. If you tried making changes to your website and facing issues because the .htaccess file is corrupted, you could just copy-paste the following code to your .htaccess file by removing the entire code in it. This will reset the .htaccess file to its default and any complications caused by an invalid .htaccess configuration will be resolved.
The default .htaccess file code
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
The extra code in the .htaccess
If you are using a WordPress caching plugin such as WP Rocket, it will automatically put certain codes in your .htaccess file between something like /*WP Rocket Code*/.
Security tools such as Wordfence or any other firewalls may also tweak your .htaccess based on the configurations. This is to ensure that your website gets the utmost security possible. However, be aware of the WordPress vulnerabilities that could impersonate such legitimate code blocks.
So, you shouldn’t be worrying about those extra lines you see on your .htaccess file. You may take a backup of the .htaccess before resetting it to default state. So that you could consult with a developer or someone who is experienced with such tasks and implement any changes you made to the file correctly.
When should you use the default .htaccess
Whenever you face some issues on your website after making changes to the .htaccess file to accomplish something. You should either revert back all the changes you made to the file or completely reset the .htaccess file to its default. If reverting the changes in the file doesn’t seems to be working, or if you are not sure what changes you made to the file, take a backup of the current .htaccess and copy paste the above code to the file and save the changes. This should make your website running fine again if the problem was caused by the .htaccess file. If not, you should diagnose the issue further.
Here is a video showcasing the common usage of an .htaccess file –
Is it safe to make changes to .htaccess?
It is completely normal to make changes to the file according to the recommended rules. Do not just copy-paste some random codes you found on the web. Whenever you are copying something from a website, make sure that the website is trusted. Implementing codes from any sneaky websites might cause you harm especially if you are new to such things. So, it is safe to make changes to the .htaccess file on your WordPress root directory only if you are going to be careful while making changes to it and use only trusted codes from trusted WordPress related websites.
How to change the .htaccess file to the default?
In order to change the .htaccess to its default, you should access it first. In most hosting provides, you will have the access to your files either through a dedicated file manager or using an FTP client. Once, you open the file, you can simply replace its content with the code given above. Rest assured, your website will start working again.