How To Create or Edit .htaccess File in Your WordPress Blog/Site

How To Create or Edit htaccess File in your wordpressWordPress .htaccess is an important system file that helps us optimize our website and improve website security. In essence, .htaccess is a configuration that the server can read.

During that process, the file allows us to configure and adjust various settings — URL rewriting, authorization, optimization, cache control, etc. One of the most common uses of .htaccess is URL rewriting.

URLs are often not understandable and people and search engines can’t read them as easily.

Hence, the .htaccess. However, even though we are talking about WordPress, .htaccess isn’t unique. All Apache-based server systems use the .htaccess file. But, WordPress is surely the most widely used website building platform.

So, in this article, we will tell show you how to create a WordPress .htaccess file.

We will also cover the purpose of the .htaccess file, and how you can use it to improve the security and performance of your website.

What is the .htaccess file?

We know that the .htaccess file might be somewhat of a hassle for beginner WordPress users, and chances are a lot of people haven’t even heard of it.

But, since WordPress is the most widespread web platform, web developers will surely encounter it at one point in their careers.

In short, the .htaccess file is a system configuration file for our Apache Web Server. We use this file to communicate with the server and specify how we want it to run our website.

If there is a .htaccess file, our website will use it every time we run it.

The .htaccess file is hidden by default and that’s why there is a (.) dot in the prefix. Hence, the hidden files are also referred to as “dotted” files.

However, .htaccess might not just be hidden — it might be missing entirely. So, what is .htaccess? What do we use it for? Where can we find it?

What Can We Use .htaccess For?

The .htaccess file lets us do a lot of things, but it’s most commonly used for creating redirects from non-www to www URLs and vice versa.

Other uses for .htaccess would be for setting certain file privileges, setting file encryption, blocking bots, blocking certain IP addresses, changing our website’s timezone, changing the default index page, adding MIME types, etc.

How To Find The .htaccess File

When we install WordPress on our Apache Server, the platform usually creates a .htaccess file. However, the file will be hidden, and we need to enable the “Show Hidden Files” option in our system in order to see it.

We also need to have administrator access to the WordPress dashboard.

If there is a .htaccess file, and we enabled the “Show Hidden Files” option, we will find it in the root directory of our WordPress dashboard, called public_html.

Now that we covered the basics regarding .htaccess, let’s dig a little deeper. Here’s a step-by-step guide on the two most common methods of creating a WordPress .htaccess file.

How to Create a WordPress .htaccess File

So far, we talked about finding the .htaccess file, but what if it’s nowhere to be found? Well, that’s not a big problem, because creating the .htaccess file is actually incredibly easy.

We can create the .htaccess file in two ways:

1) by using a Server File Manager

2) by creating it on our computer and then uploading it to the server by using an FTP client

Method #1: Using a Server File Manager

Server file managers like Hostinger and cPanel work exactly like the file manager in our operating system, whether we use Windows or Linux.

The main difference is that they’re dedicated to managing only the server files of our website, and not the files on our computer.

No matter what server file manager we use, the process for creating the .htaccess file is almost identical on all of them.

First, we need to open our hosting account control panel and locate the Files category. From the Files category, we need to open the File Manager.

The Files category is clearly visible on both cPanel and Hostinger platforms.

From the file manager, we need to open our root directory which is called public_html. Before we create .htaccess, we should check for it again by opening the file manager settings to see if the “Show Hidden Files” option is enabled.

If there is still no .htaccess file, our second step would be to create it. We just need to right-click while in the public_html directory and select “New File.”

Now we need to name the file “.htaccess” and click save.

However, we’re not finished yet.

So, now we have a text file named .htaccess, but it is empty and useless to us. In order to complete it, we have to input certain information.

In order to finish creating the WordPress .htaccess, we have to open the file with any text editor and input the following text:

# 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]


# END WordPress

This method for adding .htaccess is easy and fast, while the other method will be somewhat more complicated. However, we will mention it as well because it will pay off in the long run.

Method 2: Uploading the file using an FTP Client

In this method, the process for creating the .htaccess is the same; we are just creating it on our operating system.

We just need to right-click our desktop, create a text file named .htaccess and input the previously mentioned lines of code.

The difference, however, is that now we have to upload the file to our server before we can use it.

Firstly, we need an FTP program. We recommend FileZilla as an efficient and free option for any content uploading with FTP.

Secondly, we need FTP credentials from our web host. If we didn’t get these credentials when we first bought the hosting services, we can request them from our hosting provider.

In order to connect to our website, we need to input our credentials into the FTP program and connect. The different fields we need to fill in are:

Host — Here we need to input our website’s URL or IP address, both will work.

Username — The username for our FTP account, provided by the host.

Password — The password for our FTP account provided by the host.

Port — When it comes to the port, we can leave the settings as they are (default); however, our host might use a different port, so we should always contact them to confirm.

Once we connect to our website with the FTP client, we need to navigate to public_html.

That is incredibly easy because public_html is the root directory where all of our files are. Finally, we need to select the .htaccess file from our computer and click on the upload button. Voilà, we now have the .htaccess file on our website.

Important Things To Know About FTP

Even though we uploaded the .htaccess to the server, we might need to register the file so that the server knows it should use it.

The easiest way for registering files for our website is by using a free plugin from WordPress called “Add From Server.”

However, we most likely won’t have to do this because this is required only for the media library files.

WordPress has a 2MB upload limit if we’re using the dashboard for uploading, which is more than enough for a small file like .htaccess.

But, it will most likely not be enough if we plan on uploading anything over 2MB, which media files are sure to exceed.

So, we can avoid this problem by using FTP to quickly add any files to our website.

How to Edit The .htaccess File

Now that we finally have the .htaccess file, we can finally start working on our website further. We can easily edit the.htaccess file with the same methods we used for creating it.

We can edit it by using our server file manager. Furthermore, we can also edit it locally and then upload it by using an FTP client.

However, there is another method that is worth mentioning.

We can edit the .htaccess file by using the Yoast SEO Plugin, or the WP Htaccess Editor plugin. With these two, we can edit .htaccess directly from our WordPress dashboard.


Even though we talked about WordPress, the .htaccess file isn’t specifically unique to it. Every Apache-based web server uses .htaccess files for system configuration.

Moreover, the first time we run our website, Apache creates a .htaccess file by default. However, due to some internal bugs or wrong access privileges, that isn’t always the case.

So, in this article, we learned how to create a WordPress .htaccess file, its purpose and how to use to improve our website. We also learned how to use FTP to quickly manage the files on our website, which will surely be useful in the long run.

How To Create or Edit htaccess File in your wordpress

Leave a Reply

Copy link
Powered by Social Snap