One of the most frequently overlooked SEO factors is page load speed. There are loads of things that can be done to improve that, but clearly one of the easiest is to make your files smaller. Whilst actually using smaller files is the right thing to do, compressing the files can be done very simply by using the file .htaccess for compression.
What is the .htaccess File?
The .htaccess file is a simple ASCII text file that can change some configuration directives on an apache web server, and quite a lot more. Do note that the file name is “.htaccess” i.e. dot-h-t-a-c-c-e-s-s – this makes the file invisible under normal circumstances. You can place an .htaccess file on any folder on your site. If you place the .htaccess file in your web root (the main folder of your web site) the directives and commands you place in the .htaccess file will have effect on all sub-folders. If you place an .htaccess file in a sub-folder on your webserver, it will override the .htaccess file that you have in your site main folder. Commands and/or directives in an .htaccess file are placed one on each line, and you can add comments by using the hash symbol “#” at the beginning of the line.
These are the steps to using your htaccess file for compression
How Do I Edit the .htaccess File?
Log on to your cPanel, and click on File Manager (you must choose to view hidden and system files) and go to the main directory of your website. If this is your main domain it will be within the root html directory (often called public_html). If this is a sub-domain or add-on domain, it will be within the root html directory (often called public_html), and then your domiain name.
If the .htaccess file doesn’t exist, you can create it. Click on “Add File” (or “+ File” or “New File” – versions of cPanel can differ) and when prompted type in .htaccess – this will create an empty .htaccess file.
Click on the file, then click on edit and, after you have accepted the warning, you will be editing the content of your .htaccess file. If you have just created the file, then it will obviously be empty, but you may already have some commands in the file – don’t delete these just add to what is already there.
If you are a WordPress user and you use the Yoast SEO plugin, you can edit your .htaccess file from within your Admin Panel in WordPress. Select SEO > Tools and you will be provided a menu page – just select “file editor” and you will be offered your .htaccess file to edit.
Using .htaccess for compression
To use .htaccess for compression you need to simply add some code to your file, just copy the code below and paste it into your open .htaccess file – this will work for most servers:
If this doesn’t work (and don’t worry, it will either work or not work, it won’t break your site) then adding the following text to .htaccess for compression will work for your site:
Now all you have to do is save your .htaccess file and you have used compression to reduce your file sizes by using .htaccess.