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
- Create a new .htaccess file if you already don’t have it.
- Insert the below htaccess code
## Error Page
ErrorDocument 404 /preventDirectory/
## Remove the "#" at the beginning of the next line to turn off directory indexes.
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
Options All -Indexes
Rename the preventDirectory from your own directory or the name of file.
- That’s it you are done. Just upload the file to the root and enjoy.