htaccess Guide for WordPress Sites

Here’s what you need to know.
Q: What is a .htaccess file?
A: htaccess is short for Hypertext Access, and is a configuration file used by Apache-based web servers that controls the directory that it “lives” in–as well as all the subdirectories underneath that directory.

Q: How to find the .htaccess file?
A: The file can be accessed through either your
cPanel > File Manager (Show hidden files)
FTP / SFTP, which you can create through your cPanel. (Recommended) 🙂

My NOTES: (Lines with the hashtag ‘#’ symbol are comments.)

## Add this under RewriteEngine On for redirects.
## When you are trying to redirect visitors from your old URL.
RewriteCond %{HTTP_HOST} ^ [NC,OR]
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301,NC]

## Codes below will help with improving Speed and SEO
# BEGIN WordPress

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress


Header set Connection keep-alive

## End of Keep alive

#Add this line of code to .htaccess file (for expires tag error removal)

# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault “access plus 1 month”
# My favicon
ExpiresByType image/x-icon “access plus 1 year”
# Images
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType text/css “access 1 month”
# Javascript
ExpiresByType application/javascript “access plus 1 year”


mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_include mime ^text/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_include handler ^cgi-script$


# START – Disable server signature #
ServerSignature Off
# END – Disable server signature #

If you have questions or need any help understanding and implementing these changes, please let me know at

Tools we are proud to recommend

Set an appointment with a specialist
to get the support you need.

WP Quick Support strives to ensure the protection of your personal information through responsible practices. All personal information collected by WP Quick Support is done so exclusively with your consent, by means of a form posted on our website, an email received from you or by telephone. No information is collected automatically.