10 reasons why programmers 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.