What else can you do with the .htaccess file?
This guide explains how else you can use the .htaccess file
This guide explains how else you can use the .htaccess file
To prevent users from listing all the files contained in a directory in the absence of an index (.cgi, .html, .php etc ....), create an .htaccess file containing the following line:
Options -Indexes
If you want to use custom error messages or associate each type of error with an associated error page, create a .htaccess file containing the following lines:
ErrorDocument error number
message_or_destination
Replace "error_number" with the corresponding number. The most common errors are as follows:
Replace "message_or_destination" with the action to take. To display a simple message, type the following message in inverted commas. To redirect to a page, use the file's access page. Here are to examples, to clarify:
ErrorDocument 403 "Sorry, you do not have the right to access this file"
ErrorDocument 404 http://www.domain.com/404.php
You can also redirect the error to a CGI script which will show a message
You can also redirect the error to a CGI script that will display a message, redirect the visitor to another file depending on the URL that was originally requested (available in the REQUEST_URI environment variable), and/or send an email, etc. To do this, add the following line to your .htaccess file:
Errordocument 404 /cgi-bin/error.cgi?type=404
You only need to make an adjustment if the page requested is in https (SSL). In this case, you have to add:
Errordocument 401 /~login/error.html
If that doesn't work, check the Internet Explorer properties > Advanced tab and then untick "Show simplified HTTP error messages".
The server default for a directory's default file is index.html, index.htm or index.php. If you want to set your DirectoryIndex to another file,you can insert the code format to your .htaccess file:
DirectoryIndex file_name
For example, if you want to use the home.html as the index page, add the following code:
DirectoryIndex home.html
Join our community of users on https://community.ovh.com/en/.
Please feel free to give any suggestions in order to improve this documentation.
Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.
Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.
Thank you. Your feedback has been received.
Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.
Discuss with the OVHcloud community