What is .htaccess File?
The .htaccess file is created on its own when you install WordPress for the first time. It’s an extremely important file that allows you to give specific instructions to the hosting server. The file is used for carrying out functions like redirects, modifying website configuration and even securing your WordPress site.
How to Find the .htaccess File in WordPress?
The .htaccess file is generally hidden. The reason being it’s a very important file and WordPress wants to protect it from any potential danger such as being accidentally deleted.
To find the .htaccess file, you’ll need to log into your WordPress hosting account and navigate to the cPanel. From there, launch the File Manager and then select the public_html folder.
Since the .htaccess file is hidden, you’ll need to make it visible by selecting Setting which is generally located up in the right-hand corner of the cPanel File Manager. As soon as you select Settings, a window pops out. From there, select the option Show Hidden Files.
Now, go back to the public_html folder and the .htaccess will should be visible.
Now that you know how to find the file, let us show you how to edit it.
How to Edit the .htaccess WordPress File?
There is more than one way of editing the .htaccess file. In the next few paragraphs, we are going to show them all.
- Edit htaccess WordPress File From cPanel
- Edit htaccess WordPress File Using FTP Client
- or Edit htaccess WordPress File With a Plugin
1. Editing .htaccess File From cPanel
Step 1:
Log into your hosting account and then navigate to cPanel and select File Manager.
Step 2:
From the File Manager, go to the public_html folder. The .htaccess file is located in this folder. When you find it, right-click and select Edit.
That’s it. Now you can insert snippets of codes to make modifications to your website.
You can add below code into your .htaccess file to make it default again. Below is the default code for WordPress.
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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
Copy and paste above code into your htaccess file and save.