10 reasons why webmasters should use .htaccess files

I am not sure all of you might have heard of htaccess files. Also may be thinking what can be done having an htaccess file on your site. The people who would have heard would have used to implement custom error pages and for protecting directories which needs a password access. But htaccess file can do more than that. Below I have mentioned few quality tips on how to use .htaccess files for webmasters to their advantage.

1. For Password Protection – If you have a specific area or folder that needs to be protected and only certain people should have access to it. Then .htaccess is your answer. There are several client side based scripts to protect your password which is not secured but using server side htaccess you are safe.

2. Block users with their IP – If you think you need to deny access to certain IP address or blocks. You can also allow and deny by domain name rather than the IP address.

3. Block referrals sites – If you think certain sites is misusing your content or images and hot linking without a legitimate one then you can block them through htaccess. An apache mod rewrite is required to be installed on to the server first most servers have them.

4. 301 redirects – 301 redirect is the most effective and Search Engine Friendly method for redirecting a web page. It’s not a difficult task to implement it will preserve the ranking and credibility of that particular page.

5. 404 error pages creation – Everyone get frustrated when they encounter a broken link page. But you can help the users by creating a custom 404 error page and tell them that this pages doesn’t exist which will make the reader to think that you care them.

6. Prevents from access htaccess – htaccess files allow you to prevent accessing certain part of your website. htaccess also can protect certain directories as password protect folders and give access to only specific users.

7. Create user friendly URLs- With htaccess and an apache module called mod_rewrite you can setup URLS in which ever way you want. Often ecommerce and a website on content management software generate URL with many special characters which are not search engine friendly. But with .htaccess file you can mod_rewrite them.

8. Enabling server side includes- One of the trickiest aspects of a maintaining a website is constant update on a certain part of the design which occurs on every page. But with Enabling server side includes instead of copying and pasting the new code on all the pages you can use a include file which will modify and will replace all the pages. You should also be able to do that using .htaccess

9. Set time zone of your server- You can set server time zone to local time zone using htaccess which will give the correct time being return in your web form.

10. Block bots and Cache of the web pages- Another advantage of htaccess is for blocking bots and caching of your web page by the search engines. This can be prevented too by htaccess.

htaccess is one of the smallest things that we all overlook. but I see many things I have listed here are very invaluable tool for a webmaster.

Comments

  1. says

    This is a great and informative post. I have used the .htaccess file in the past to do 301 redirects and for custom Error pages, but this lays out all of the great uses for the .htaccess file.

  2. says

    Arthur, Thanks for commenting, webmasters often forget about the valuable use of .htaccess. It can be used for several other purposes than the 10 I have mentioned.

  3. says

    Thomson, im already using htacces for most rules you mentioned here but i cant seem to set the timezone to the correct one (clients timezone), could you help me with that? Is there a way to show my users their own time?

    Niels Marsman

  4. sunil says

    Thanks u very muchhhhhhhh.
    I was looking for this since days.
    Thanks buddy.
    Wish u all the best for rest of life.

  5. Jon says

    Is it necessary (and possible) to prevent access to the sitemap.xml file and, also, to the .htaccess file itself? I ask this because, for instance, there’s good reason to also prevent access to your .css file, javascript files and Templates folder. As a test I’ve attempted accessing sitemap.xml and .htaccess files in a couple of websites and was directed to a ‘Forbidden’ page. Is this an automatic outcome in all cases or is it manufactured?

Leave a Reply

Your email address will not be published. Required fields are marked *