[email protected] +91-120-6025102

Avail Best discounts

Please fill in the form below and we will contact you within 24 hours.

What is the .htaccess file and where can I find more information about it?

An Introduction to .htaccess Tutorial

In this tutorial, you will learn about the .htaccess file and its influence on your website development. Although, .htaccess is only a file that can make changes in the settings on the servers and permits you to do various different things, the most widespread being capable of having your own custom 404:error pages. The .htaccess is not hard to use and is actually made up of a few meek instructions in a text file. Hostmonster supports .htaccess files; however, as a costumer you are accountable for what is present in the file and how it alters your site.

There is a wide range of information available about .htaccess which includes: redirecting users automatically, password protecting folders, changing your file extensions, custom error pages, banning users with some of the IP addresses, stopping directory listings, only allowing users with certain IP's and using a different file as the index file. Many of these can be done through point and click straight from the Hostmonster control panel.

Creating A .htaccess File

Creating an .htaccess file may create few problems for you. Writing the file is easy; you just have to enter the suitable code into a text editor (like the notepad). You may face several problems with saving the file because .htaccess is an odd file name (the file really has no name but it has an 8 letter file extension) it may not be recognized on few systems (e.g. Windows 3.1). With most of the operating systems, all you need to do is to save the file by feeding the name as:

(Do not remove the quotes). If this does not work properly, you will then have to name it something else like htaccess.txt) and then you can upload it on the server. Once you are done with uploading the file, you can then rename it by using an FTP program.

Warning: Before you begin to use .htaccess, I should warn you about something. Although using .htaccess on your server is almost implausible to cause you with any glitches (if anything is wrong it simply would not work), you should be cautious if you are working on Microsoft FrontPage Extensions. The FrontPage extension uses the .htaccess file, so you should not actually edit it to add some of your own facts and figures.

Custom Error Pages

The first thing that you use in the .htaccess file is 'custom error pages'. This will permit you to have your own 'personal error pages' as a replacement of your host's error pages. This will make your site much more professional in the improbable event of an error. It will also allow you to create scripts to notify if there are any errors.

You can use 'custom error pages' for any kind of an error as long as you know the error number by adding the below mentioned to your .htaccess file:
'ErrorDocument errornumber /file.html'
For example if I had the 'file not found.html' in the root directory of my site and I wanted to use it for a 404: error I would use:
'ErrorDocument 404 /notfound.html'
If the file is not in the root directory of your site, you just need to put the path to it:
ErrorDocument 500 /errorpages/500.html
These are some common errors which are likely to be seen:
401 - Authorization Required
400 - Bad request
403 - Forbidden
404 - Wrong page
500 - Internal Server Error
At the end, all you need to do is to make a file to display when the error occurs and upload it and the .htaccess file.

Was this answer helpful? #4 #0

Related Questions

Submit Query

Please fill in the form below and we will contact you within 24 hours.