How do I enable .htaccess in WordPress?

This tutorial shows how to enable, edit or update the .htaccess file in WordPress websites.

The .htaccess is a configuration file implemented to modify Apache web server settings. It can be used to redirect websites, permalinks, URLs, implement password protection, and more.

This file is vital for the website to work properly. Any misconfiguration in the .htaccess can lead to an error when trying to access a site.

After reading this tutorial, you’ll know how to enable this configuration file from WordPress and some additional tips related to the .htaccess file.

Enabling the .htaccess file from WordPress

To begin, access your WordPress Dashboard; usually, you can access it through https://<YourDomain>/wp-admin (Add /wp-admin after your domain).

You’ll see the login form, fill in your username and password to access your WordPress dashboard.

Once logged in, on the left menu, find Settings, as shown in the screenshot below. Then, press Permalinks.

The screenshot below shows where Settings and Permalinks options are located.

Once the permalinks page shows up, scroll down and simply press the Save Changes button, shown in the following image.

Now the .htaccess file was generated in your server root path.

Enable or edit the .htaccess file from Cpanel

If you have access to Cpanel, you can create and edit your .htaccess file from the Cpanel Files Manager.

Login to your Cpanel account, and within the main screen, scroll down and select the Files Manager shown in the screenshot below.

Move into your website’s main directory, where directories wp-content, wp-admin, etc., are located.

On the left upper corner, you’ll see the option +File, press it to create a .htaccess file.

The box to fill the file name will show up, type .htaccess (don’t miss the dot), and press the Create New File button.

Now your .htaccess file is created but empty. To edit or add content, right-click on the .htaccess file and press Edit.

A new box will appear for you to specify special encoding if necessary. If you are working in English, you can just ignore it and press the Edit button.

As said previously, if you created your .htaccess file from Cpanel, it will be empty.

Below there is a sample of the default WordPress .htaccess configuration. You can copy and paste it within your .htaccess.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

On Cpanel, the file will seem as shown below.

On the right upper corner, press the Save Changes blue button to apply the new configuration.

Now your .htaccess file is ready with a default configuration.

Enable or edit the .htaccess file from FTP

This section shows how to create a .htaccess file from an FTP client. For this tutorial, I will use the Filezilla FTP client.

Before starting, you need to create a file called .htaccess (Don’t forget the dot) with the following content and keep it on your computer; we will upload this file using the FTP client.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Once your .htaccess file with the default configuration is created, you can open your FTP of choice.

Below you can see a screenshot of Filezilla, the FTP client used for this tutorial.

You will see 3 fields to fill; normally, all FTP clients contain the same fields, which include:

  • Host: Here, you specify your FTP address (e.g., ftp.yourdomain.com).
  • Username: Your FTP username.
  • Password: Your FTP password.

Once you type your FTP server address, username and password, press the Quick Connect button to establish the connection.

Once connected, select your site root directory, and on the left side window showing local files and directories, right-click on the .htaccess file you created in the first step of this section, and press the Upload option as shown in the screenshot below.

After uploading the ,htaccess file, you can refresh the remote view, and you will see the .htaccess file (In my case, it was created months ago).

To edit your .htaccess through FTP, you’ll need to create a new edited .htaccess file and upload it replacing the old one. When doing this, it is highly recommended to keep the old working .htaccess file as a backup.


I hope this tutorial explaining how to enable the .htaccess file in WordPress was helpful.

When working with websites, dealing with .htaccess is a must. From the technical viewpoint, marketing professionals must also deal with the .htaccess file to define proper redirects for SEO purposes.

Therefore as you can see, the .htaccess file is important in many fields, including security and marketing, among other usages. For example, you can use your .htaccess to redirect all traffic through https, even when visitors try to reach your site using http; that’s what plugins forcing SSL actually do.

As you can see, generating a .htaccess file or editing it isn’t a hard task, and the internet contains a lot of examples and instructions to apply available functions

Thank you for reading this article about the .htaccess file and WordPress; keep following us for additional tips and tutorials.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.