.htaccess Tutorials & Tips

12 Most Used .htaccess Examples, Tips – Commands & Directives

Updated: added a 301 redirect directive.

Whatever you wanto call this, a cheat sheet, a real thin manual, or anything, we simplify the use of .htaccess as much as possible and make it do more for you with less hassle.

  1. Unify and!
    # Use a 301 redirect from to to tell SEs that the 2 domains are the same thing so there's no PageRank leakage.
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^kavoir\.com [NC]
    RewriteRule ^(.*)$$1 [R=301]
  2. Block spammers!
    # This blocks and * from accessing your site.
    <limit GET POST PUT>
    order deny,allow
    deny from
    deny from
    allow from all
  3. Change default page!
    # The order is followed as specified:
    DirectoryIndex default.htm default.php index.html index.php
  4. Enable directory browsing!
    Options +Indexes
    # block a few types of files from showing:
    IndexIgnore *.wmv *.mp4 *.avi
  5. Disable directory browsing!
    Options All -Indexes
  6. Customize error messages!
    ErrorDocument 403 /forbidden.html
    ErrorDocument 404 /notfound.html
    ErrorDocument 500 /servererror.html
  7. Get SSI working with HTML/SHTML!
    AddType text/html .html
    AddType text/html .shtml
    AddHandler server-parsed .html
    AddHandler server-parsed .shtml
  8. Redirect it!
    Redirect oldpage.html
  9. Block visits or leeches from specific referers!
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
    RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
    RewriteRule .* - [F]
  10. Stop a file from being viewed!
    # mycontacts.txt cannot be accessed by any means:
    <files mycontacts.txt>
    order allow,deny
    deny from all
  11. Password-protect a directory!
  12. Change script extensions!
    # anyfile.kv will be treated like a PHP script:
    AddType application/x-httpd-php .kv
    # anyfile.kvcgi will be treated like a CGI script:
    AddType application/x-httpd-cgi .kvcgi
Kavoir & Whatever

You are powering the web, get noticed today!

The quickest way to get started on publishing on the web, 8 out of 10 people would agree, is blogging. Blogging is very effective in communicating, especially after the entry into the era of web 2.0. People have come together to urge a global community to form. Ideas are more easy than ever to share and spread. Most bloggers are happy blogging, showing off their personalities, writing for the world to read, and reaching to an audience that’s interested in him or her. Content put online has exploded to its double, triple, and even more. These are exactly the essence of web 2.0. That is.

We power the Web.

Money is being made through blogging, too. A considerable small portion of those who blog are earning a decent living by blogging alone. Yes. Many are full time bloggers, like dear Darren Rowse. Although most of us can’t afford giving up daily job and maintain a career like this, blogging in your spare time does make your life better. And others.

Only connect.

Everyone is unique. Everyone has something to offer to the community. Contribute what you know, help others as you can, and you’ll be rewarded. Web is the best boss I know of as of now. He’s smart, unbiased, knows the answers to almost all your questions; rewards hard work and creativity. Work for him, and you won’t regret it.

Get noticed today, if you don’t have a blog yet, start one! Talk anything you like, your newly bought climbing gear, your annoying little brother or the book you just read. As you keep reading other people’s blogs and writing your own, you will be more clear in where you are heading. What to express, what your blog is going to be like and how to make people excited about what excites you!

Blogging systems I would recommend to first time bloggers, are Google Blogger and As 2 maturely developed blogging systems, they are both free, and justify their incredible popularity with full-fledged features and easy to use functionalities. Signing up is as simple as 3 steps, very probably in 5 minutes, you will be struggling to figure out what to say in your first post that declares your presence to the online world. Don’t panic in case you can rarely put together enough to talk about, and don’t worry about what other people might think of it. It’s normal. However, sticking on it will eventually pay off, both socially and financially.

Just speak out!

Writing is a good way to organize your thought, it keeps you smart along with discussion with other people. Your thoughts are precious. Write them down, and be confident of them. In this way, you grow and your blog develops.

More inspirations:

  1. WordPress Codex: Introduction to Blogging
  2. Start Blogging Online: How To Start a Blog – A Complete Beginner’s Guide
  3. Wikipedia: Blog
  4. M. Sean Gilligan’s Introduction to Blogging
  5. Darren Rowse and his ProBlogger