How to Edit the .htaccess File in WordPress?

WordPress is the world’s most popular website-building platform for a reason. It takes close-to-zero technical expertise to manage a website on WordPress. However, knowing about some of the important files and folders will make your life much easier. One such file is the htaccess file.

If you are running and managing websites on WordPress for a while, you must have stumbled across the need to access or edit the file.

In this article, we’ll show you two ways of accessing and editing the file. Before getting into it, let us dive a little into what the htaccess file actually is.

What is the .htaccess file?

It is one of those files that are created by default when you install WordPress. This file is extremely important as it enables you to provide specific commands to the hosting server. The file is used to perform instructions such as redirects, changing website configuration, securing your website, and so on.

For example, if you want to restrict access to a particular page because you are making changes to it, so it allows you to secure it with a password. WordPress stores it in the root folder of the WordPress install, i.e. the public_html folder. In the next section, we talk about how you can find it.

How to Edit the .htaccess File in WordPress

Before we proceed to discuss the various ways in which you can edit the it, we advise you to take a complete website backup before editing it. The importance of a backup cannot be emphasized enough. To begin with, there is the risk of accidentally deleting the file or modifying it incorrectly. Furthermore, the modifications may not turn out as you want them to. Hence, taking a full website backup is strongly advisable.

We’ll take a look at two methods of editing the htaccess file in WordPress.

  • Directly from cPanel
  • Using a Plugin

You can also use an FTP client to edit your htaccess file. However, these two methods are the simplest.

Method #1: Editing .htaccess file using cPanel

Step 1: Log into your cPanel account provided by hosting provider

.htaccess file

Step 2: Locate the Files section and click File Manager.

.htaccess file

Step 3: You will see various files and folders. Navigate to the public_html folder to locate the .htaccess file.

Step 4: If you can’t find the .htaccess file, go to Settings on the upper right menu and tick the Show Hidden Files option to enable viewing.

Enabling the showing of hidden files on cPanel.

Step 5: Right click on the .htaccess File and hit Edit or check the Edit button as shown in below image to open it. You will see the .htaccess file opening in another window where you can make changes to it as per your requirements.

Method #2: Editing .htaccess file using the Htaccess Editor plugin

The method mentioned above has a little element of risk involved. It includes accessing and editing WordPress files manually which can go drastically wrong. Using the Htaccess Editor plugin is a safer method. You’ll find various plugins for the function of editing the .htaccess file on WordPress. However, the Htaccess Editor plugin offers a straightforward and simple process to edit the .htaccess file.

It is always advisable to stage your WordPress website and test the plugin to check for compatibility issues. However, the plugin is highly unlikely to cause any of those. So, let’s move right into the process of installing and setting up the plugin.

  1. Click on Plugins in the left sidebar of the admin dashboard and then hit Add New.
  2. Search for “Htaccess Editor” and find the plugin by WebFactory Ltd. Install the Htaccess Editor plugin and activate it for your WordPress site.
  3. Once activated, you can use the plugin by navigating to Settings in the admin dashboard and clicking on WT Htaccess Editor. It will take you straight to the .htaccess file without even leaving the dashboard. You can now edit the .htaccess file as per your requirements and save the changes.
Edit-the-.htaccess-File-in-WordPress.

You may also like...