Options, IndexOptions, DirectoryIndex, ErrorDocument with .htaccess

1. Authorization and prohibition on listing the content of the folder

When you open a website address (URL), which has no index file by default (index.html, index.htm, default.html. etc.) the browser will display a list of files and folders.

Displaying files and folders in this situation may be prevented.

To enable display of files and folders to allow the server to show a list of files to a folder, use the following line in .htaccess file:

Options + Indexes

To disable display of files and folders and return an error (Error 403), add this in .htaccess:

Options-Indexes

2. Style of the list of files and folders

You can show a different list of files and folders, including icons, file size, modification date, etc. by entering:

IndexOptions + FancyIndexing

Exclusion of this style by:

IndexOptions-FancyIndexing

Use the top row, if you want the regular list of files and folders.

3. Changing the default index file

To change the default file (index.html, index.htm, default.html. etc.) of certain file chosen by you (for example) novfile.html, add the following line in .htaccess file:

DirectoryIndex newindex.html

4. Customizing and editing pages for errors

When an error occurs because a calling of nonexistent file or error occurred in the performance of the query , it shows standard error pages. To make your own error pages, change .htaccess file using ErrorDocument and 3 digit code for the relevant error:

ErrorDocument 404/404.html

This will display the web page 404.html, if the document you are looking for is not found.

You can also display text messages instead of file:

ErrorDocument 404 “The document was not found”

There are other error codes such as:

401: Authorization required (part of the site protected by username and password).

403: Forbidden (part of the site, which is prohibited)

500: Internal Server Error (wrong permissions of a file or in the wrong order in .htaccess)

  • 192 משתמשים שמצאו מאמר זה מועיל
?האם התשובה שקיבלתם הייתה מועילה

מאמרים קשורים

Add your own php.ini file to the crontab command

If you want to use your own php.ini in the implementation of cronjobs, add the following to the...

Can I use short tags in PHP scripts

Yes you can. The settings of PHP (short_open_tag) allow you to use short tags in PHP scripts.

How to do URL redirection

You can do URL forwarding from the web hosting control panel. Once logged in click on Redirects....

How to increase the size of uploaded files in PHP

The standard maximum size of the file that you can upload in PHP is 2MB, but some scripts require...

How to turn off register_globals in PHP

In each directory where you want register_global to be turned off, place the following php.ini...