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:
Start by opening FileZilla.
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.
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.
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.
Start by opening Notepad.
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
Next, open FileZilla.
After you’ve connected to your site, right-click your .htaccess file within the left-hand menu and click Upload.