Important htaccess commands for blog and websites

It doesn’t matter which kind of web hosting you are using Shared or VPS. In both servers htaccess commands have its own important contribution which can impact your search engine option and many other things. Such as speeding up your blog, enable cache, redirection of the domain name and much more.

1. Enabling GZIP using htaccess commands:

By enabling GZIP for your blog or website you may increase its loading time up to 30-50% faster. It is best to compress the HTML to reduce your website size in addition to page running times. This will help your website retain visitors and improve page opinions.

Setting GZIP using htaccess commands on Apache server: Most of us using apache server for their web hosting service which means you can directly follow our instructions and turn on GZIP by adding a few deflate codes to your htaccess file.

# compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

 2. URL Canonicalization Redirection:

In this case, you can redirect your non-www URL to www URL. It creates a confusion between the search engine and your exact URL. It becomes hard to determine which one your correct URL need to be indexed by Google or other search engines. By adding few lines in your htaccess file you can easily resolve this issue.

If you want to redirect www to non-www URL:

RewriteCond %{HTTP_HOST} ^www\.example\.com$

RewriteRule ^/?$ “http\:\/\/example\.com\/” [R=301,L]

If you want to redirect non-www to www URL:

RewriteCond %{HTTP_HOST} !^$ [NC]

RewriteRule ^(.*)$$1 [L,R=301]

3. Libwww-Perl Access:

Check in case your server makes it possible for access from User-agent Libwww-Perl. Botnet scripts which automatically seek out vulnerabilities in your software are sometimes identified since User-Agent Libwww-Perl. By preventing access from Libwww-Perl it is possible to eliminate quite a few simpler problems.

RewriteCond %{HTTP_USER_AGENT} libwww-perl.*

RewriteRule .* – [F,L]


Know this GoogieHost Writer 😂

Rajesh Chauhan

GoogieHost is one of the leading free web hosting provider on the internet over 300000 satisfied clients across the globe. We also offer Affordable SEO Web Hosting and Digital Marketing service to give give wings to your online business. Unlimited FREE HOSTING.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

/* ]]> */