Popular Posts

How to use .htaccess Part 1 : Stop directory index from shown

 Introduction:

".htaccess" is a file name not an extension. You wold not create a file called file.htaccess, it is simply called ".htaccess". This file will take effect when placed in any directory which is loaded by Apache web server. This file take effect over entire directory it is palaced.

Stoping directory index from being shown:

Sometimes, for one or another reason you will have no index file in your directory.  At that time someone types the directory name into browser, a full listing of all the files in that directory will be shown. This could be a security risk.

To prevent this you can enter a command into .htaccess file to stop directory list from shown:
Options -Indexes 

Alternative Index Files 

You may not always want to use index.html as your index file for a directory, for example you are using jsp files in your site, you may want index.jsp or any other to be the index file for directory. 

Alternative index file are entered in a list. The server will check left to right if each file exist if none of them exist than it will display directory listing:
DirectoryIndex index.jsp index.html hello.jpd new.jsp index.html index.htm

How to use .htaccess Part 1 : Stop directory index from shown How to use .htaccess Part 1 : Stop directory index from shown Reviewed by Snehal Vasava on May 19, 2018 Rating: 5

No comments:

Breaking

Powered by Blogger.