WordPress, the world’s preferred website building platform started out as a user-friendly publishing platform that quickly rose and dominated the industry. Installing WordPress and running the site doesn’t require any knowledge of the underlying files and folders. But it’s possible that one day you find yourself in a situation where some knowledge of WordPress files are required. The .htacess file is an important WordPress file that you would want to learn about. Here, we will show you how you can edit .htaccess WordPress files.
If you’ve been running a WordPress website for a long time, you must have had the need to access and edit the file at some point. Located on your web server, the .htaccess file can help you block IP addresses, restrict access to WordPress files, launching custom error pages, and a whole bunch of other things.
Modifying .htaccess is no easy task. One small slip can result in a broken website. But you don’t have to worry because we are going to walk you through the process of finding and editing the .htaccess file without breaking your site.
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.
For instance, if you are revamping your website and you want to restrict access to a page, you can password protect it with the help of .htaccess. We have a guide on How to Password Protect a Site With Htaccess, if you want to check it out.
Where is the .htaccess File Located?
The WordPress htaccess file is found in the root of your WordPress install. What does that mean? Let’s take a step back.
WordPress sites are made up of many files and folders stored in a structured manner.
To understand the WordPress file structure, think of a Russian Doll. The toy consists of a set of hollowed wooden dolls and comes in different sizes. Each doll is nested within a larger doll.
In the same vein, small website files nest inside larger folders files. The largest WordPress file is the public_html folder and it’s often called the root folder. The .htaccess file is found in this root folder.
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.Learning to work with .htaccess will come in handy because there is a wide variety of things that you can do with the .htaccess file. Click To Tweet
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
Hang On! You Should Take Backups
Before you edit WordPress .htaccess file, take a complete website backup. We can’t stress enough on the importance of the file and the risk of accidentally deleting it. Besides, the modification hoped to see on your site when you edit the .htaccess file, it may not turn out as you want it to. Or worse, it breaks your site. Whatever happens, if you have a backup, you can quickly restore your site back to normal. No sweat.
Right, now let’s show you how you can edit your .htaccess file.
1. Editing .htaccess File From cPanel
Log into your hosting account and then navigate to cPanel and select File Manager.
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.
2. Editing .htaccess File Using FTP Clients
Another way of editing the .htaccess file is to use an FTP client. For those who don’t know what an FTP client is, think of it as a tool that connects your website to your computer. Using an FTP client like Filezilla, you can access the files of your website from your local computer without having to log into your hosting account. Here’s how you can edit the .htaccess file with an FTP client.
Step 1: Install Filezilla
Download and install Filezilla (the most popular FTP client) on your computer. Once installed, open it.
Step 2: Find Your FTP Credentials
Now you’ll need to connect Filezilla to your website and to do this, you’ll need your FTP credentials. You can ask your hosting provider for it but if you wish to seek it out on your own, here’s two resources that’ll help you – how to find FTP credentials manually and videos on finding your FTP credentials.
The FTP credentials consist of 4 things – hostname, username, password and port number.
On Filezilla, there are options at the top of the window where you can insert the FTP credentials. Once you have done that, click on Quickconnect and let the software connect to your website.
Step 3: Locate & Edit the .htaccess File
Filezilla is divided into two sections. On the left, you have the local site which shows you a bunch of files from your local computer. And on the right is the remote site which shows a bunch of files from your website.
From the remote site, select public_html folder. The content of the folder will appear in the File name section which is located right below the Remote site section.
When you find the .htaccess file, right-click and select Edit.
That’s it folks. Next, we’ll show you how to edit your .htaccess file using a plugin.
3. Editing .htaccess File With a Plugin
Editing the .htaccess file through both the cPanel and via FTP client can seem a bit risky because you have to go to the backup of the site and then edit the file. Most website owners don’t access WordPress files and it can seem a little overwhelming at first. In such a state, it wouldn’t be surprising to make a mistake. Using a plugin is a safe option.
There are quite a few plugins in the repository for editing .htaccess file but after carefully considering, we chose Htaccess Editor. The plugin has over 50,000 active installations and over two dozen 5-star ratings. From the repository page, we also learn that it’s frequently updated. Htaccess Editor ticks all the boxes for choosing the right plugin.
Before you install the plugin, however, try and stage your website and then install the plugin to check if it’s causing compatibility issues. Compatibility issues can end up causing trouble such as your site will start misbehaving and some of the plugins may stop working. Here’s a good post on how to stage a WordPress website.
Once you’ve tested it, it’s time to edit the .htaccess file with a plugin.
Install and activate Htaccess Editor on your WordPress website.
Then, on your website dashboard, go to Settings and then select WP Htaccess Editor. That’ll take you to the .htaccess file without having to leave your WordPress dashboard. Insert any code snippet and remember to save the changes.
That’s all folks!
Congratulations! You’ve taken your first step in your journey to becoming a WordPress expert. Jokes aside, learning to work with .htaccess will come in handy because there is a wide variety of things that you can do with the .htaccess file.
Moreover, having more than one way of editing the file is useful because if you find one method difficult you can try the other one. And once you get the hang of it, you can simply navigate to the public_html folder, open and edit the .htaccess file. By modifying the file, you can now add any functionality you require to your website. But before making any edits, make sure you are taking backups.
Try BlogVault Backup Plugin to Take Backups