Your public_html folder should be contain many directories like images, js, styles. Someone may be try to access these files from your site without your permission. If you think, don't allow others to access these files, then you can create .htaccess file for protect your files from them.
Syntax:
Options -Indexes
OR
IndexIgnore *
It tells the server to disable the directory listings on your site. Now you can not see your directory lists. If you try to get access it, then you will get forbidden error message.
You can also enable this features to your sire.
Syntax:
Options +Indexes
It tells the server to enable the directory listings on your site.
Normally when you access the directory list on your browser, you can get all files presented in that directory. Sometimes, you may be feel, other files will display to user except .php, .css, .js. you can done by .htaccess.
Syntax:
IndexIgnore .*php .*css .*js
Now the user can get access your files except the file with extension php, js and css
By default, the directory lists are displays just with only its name. If you want to know the additional details like its size, description, then you can done by .htaccess.
Syntax:
Indexoptions +FancyIndexing
Now you can get directory lists with additional information such as size, description, last modified date etc..
You can also disable the additional details.
Syntax:
Indexoptions -FancyIndexing
Syntax:
Options -Indexes
OR
IndexIgnore *
It tells the server to disable the directory listings on your site. Now you can not see your directory lists. If you try to get access it, then you will get forbidden error message.
You can also enable this features to your sire.
Syntax:
Options +Indexes
It tells the server to enable the directory listings on your site.
How to ignore the particular file based on its extensions in directory lists using .htaccess:
Normally when you access the directory list on your browser, you can get all files presented in that directory. Sometimes, you may be feel, other files will display to user except .php, .css, .js. you can done by .htaccess.
Syntax:
IndexIgnore .*php .*css .*js
Now the user can get access your files except the file with extension php, js and css
How to display the directory lists with other details using .htaccess:
By default, the directory lists are displays just with only its name. If you want to know the additional details like its size, description, then you can done by .htaccess.
Syntax:
Indexoptions +FancyIndexing
Now you can get directory lists with additional information such as size, description, last modified date etc..
You can also disable the additional details.
Syntax:
Indexoptions -FancyIndexing
Related Post:
What is htaccess?
Restrict users to access pages from site using .htaccess
Compressing resource with gzip using .htaccess
How to create error document using .htaccess
How to add expires headers using .htaccess
How to add MIME types using .htaccess
How to enable SSI using .htaccess
How to force script to display as source code using .htaccess
How to prevent access to php.ini file using .htaccess
How to redirect urls using .htaccess
How to redirect to www using .htaccess
How to enable short tag in php using .htaccess
How to access pages through one page in site using .htaccess
Restrict users to access pages from site using .htaccess
Compressing resource with gzip using .htaccess
How to create error document using .htaccess
How to add expires headers using .htaccess
How to add MIME types using .htaccess
How to enable SSI using .htaccess
How to force script to display as source code using .htaccess
How to prevent access to php.ini file using .htaccess
How to redirect urls using .htaccess
How to redirect to www using .htaccess
How to enable short tag in php using .htaccess
How to access pages through one page in site using .htaccess