What is .htaccess and How does .htaccess works by Bally Chohan ?

June 4th, 2010

Bally Chohan says .htaccess is a language that is used mainly for executing functions mainly involving the server. For exmaple say you want to set redirects htaccess is a best place to set redirect as well.

How to protect any folder using .htaccess by Bally Chohan ?
Lets say you want to password protect folder “Bally Chohan” for it your .htaccess file contains following instructions.

  • AuthName “Bally Chohan”
  • AuthType Basic
  • AuthUserFile /home/httpd/vhosts/ballychohan.info/httpdocs/yourusername/.htpasswd
  • Require valid-user
  • <Files .htaccess>
  • order allow,deny
  • deny from all
  • </Files>
  • How to Ban IP Address using .htaccess by Bally Chohan ?
    Now for this, there are different ways of blocking the IP address.
    Create another .htaccess file – but put this in your main directory. Now this is where it gets a bit more tricky.

    There are different ones to choose from.
    A)  “deny from all”
    this will block every single IP address known to existence.

    B) deny from 000.000.000.00.0
    this will block the IP address from the exact address shown.

    C) do the same but instead of “deny” change it to “allow” this will do the opposite of the one mentioned above.

    How to Customized Error Pages by bally Chohan?
    ErrorDocument 404 http://www.ballychohan.info/404_Error.html
    This script makes the page “404_Error.html” appear every time a 404 error happens.

    To do the others such as: 401 Error – Unauthorised access, you change it to:

    ErrorDocument 401 http://www.ballychohan.info/403_Error.html

    Bally chohan says there are lot of configuration which we can do through .htaccess. Bally chohan try to highlight few of then here. Bally chohan would like to explore more in its future posts.

    Categories: Tutorials

    Leave a comment

    Leave a comment