Learn Allow, Deny, Disable, Enable Directory Listing In .Htaccess

Unknown Reply 9:01 PM
When a web browser is pointed to a directory on your web site which does not have an index.html file (or any other index file) in it, the files in that directory can be listed on a web page.
Let us see few snippets that can be added in htaccess file to allow or avoid directory listing in apache server.

Enable / Disable directory Listing

To allow a web server to produce a directory listing, whenever you point a directory without index file. Add following line in your .htaccess file.
Options +Indexes
# or #
IndexIgnore *
allow-directory-listing-htaccess
To disable or prevent the directory access add following line in your .htaccess file. If user points the browsers to a directory which does not have index file then in this case 403 error will be
Options -Indexes
Following is the error page that gets displayed when we try to access any directory without index file.
403-directory-listing-error-htaccess

Change Listing style

You may want to display other details while showing the directory listing. This includes file icons, file size, modification date and more. This can be done by adding fancy style to your htaccess file. Add following snippet in .htaccess file.
IndexOptions +FancyIndexing
fancy-directory-listing-htaccess
To remove the fancy directory listing or to display normal directory listing, use -FancyIndex.
IndexOptions -FancyIndexing

Ignore files with specific extension

It may happen that you may need to ignore certain files to get displayed in directory listing. This can be achieved using IndexIgnore directive in .htaccess file.
Following snippet will not display .zip and .txt file in directory listing.
IndexIgnore *.zip *.txt

Modify Index File

It is possible to change the default index file from index.html (index.php, index.jsp …) to any other file. Following line will change the index file to Home.html.
DirectoryIndex Home.html

What function of @ in PHP ???

Unknown Reply 11:00 AM
That is Error Handling.

The @ is error suppression operator in PHP.
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
See:

Update:

In your example, it is used before the variable name to avoid the E_NOTICE error there. If in $_POSTarray, hn key is not set, it will throwE_NOTICE message but @ is used there to avoid that E_NOTICE.
Note that you can also put this line on top of your script to avoid E_NOTICE error:
error_reporting(E_ALL ^ E_NOTICE);

PHP6 Note:

Because @ operator is very slow, it won't work on ini_set eg @ini_set.
You should avoid using it where you can.
Source : http://stackoverflow.com/questions/3551527/php-at-symbol-before-variable-name-post

Search

Ikuti Channel Youtube Aku Yaa.. Jangan Lupa di subscribe. Terima kasih.

Popular Posts

Translate