A guide to .htaccess files for WordPress

This article will explain what .htaccess files are and how to find/add one to your WordPress site.

What is a .htaccess file?

Every WordPress site comes with a .htaccess, or ‘hypertext access’, file as standard, which consists of a series of rules that instruct the Apache server for your website. As such, this file can be used to configure your site’s functionality, which can include:

  • Setting up redirects
  • Password-protecting your directories
  • Displaying a custom Error 404 page
  • Compressing your site

Where can I find my .htaccess file?

You can find and edit your default WordPress .htaccess file by connecting to your site via FTP. To do this, simply follow the instructions outlined below:

Step 1 of 3

Start by opening FileZilla.

 

Step 2 of 3

Once connected, your .htaccess file can be found below your main folders within the right-hand panel. To view it, simply right-click your .htaccess file and select View/Edit.

Enter FTP Details

 

Step 3 of 3

Once connected, your .htaccess file can be found below your main folders within the right-hand panel. To view it, simply right-click your .htaccess file and select View/Edit.

View htaccess file

If, however, you don’t see a .htaccess file within your folders, you will need to add one to your site.

 

How do I add a .htaccess file?

Although every WordPress site includes a .htaccess file, you can add multiple files to stipulate certain rules.

However, having multiple WordPress .htaccess files can affect your server’s performance so we recommend downloading a copy of your existing .htaccess file before getting started.

Step 1 of 5

Start by opening Notepad.

 

Step 2 of 5

Next, paste the following code and then save your document as .htaccess

# BEGIN WordPress

<IfModule mod_rewrite.c>

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]

</IfModule>

 

# END WordPress

Step 3 of 5

Next, open FileZilla.

 

Step 4 of 5

Enter your FTP details into the provided fields and click Quickconnect.

Enter FTP Details

 

Step 5 of 5

After you’ve connected to your site, right-click your .htaccess file within the left-hand menu and click Upload.

Upload htaccess