Blog for web developers

Htaccess forbidden access code to show error

Htaccess forbidden acccess code to show error.

I was wondering if I could find the solution to block my directory from being access by the users or webmasters. We don’t need a hard php code for it to block directory. Its possible with the help of .htaccess code only. Below is the code for Htaccess forbidden access code to show error.

Follow the below procedure to prevent folder from being access by htaccess

  1. Create a new .htaccess file if you already don’t have it.
  2. Insert the below htaccess code

    ## Error Page
    ErrorDocument 404 /preventDirectory/

    ## Remove the "#" at the beginning of the next line to turn off directory indexes.
    Options -Indexes
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    Options All -Indexes

    Rename the preventDirectory from your own directory or the name of file.

  3. That’s it you are done. Just upload the file to the root and enjoy.

Santosh Shah

I am a JavaScript developer having enthusiasm on most frontend skills like JavaScript, HTML, CSS, SASS, node, gulp, angular etc. I love exploring new techniques and like to learn new technologies to keep my self up to date.

Leave a Reply

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

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