 |
In this tutorial you will find out about the .htaccess file and the power it has to improve your website. .htaccess isn't difficult to use and is really just made up of a few simple instructions in a text file.
What is an .htaccess file?
.htaccess is simply a text file which you can upload it to your web site. The server detects this file automatically and runs to check for special instruction every time someone access any file or directory on your web site. An .htaccess can change settings on the server and allow you to control many things. For example you can setup password protected directories, custom 404 errors, url redirecting, changing default pages, changing extension types, block or restrict certain IP Addresses, etc. There is a huge range of things an .htaccess can do.
How to create an .htaccess file
The easiest way to create an .htaccess file is to open up Notepad with a blank file and then save it as ".htaccess" (including the quotes). This will create the file and allow you to open it up later for editing. You can upload the file to your account on the Databloc servers however it would be a bit pointless as it won't change anything. But lets explain it.. To upload the file you will need an FTP Client (lookup tutorials for a guide if you do not know how to use an FTP client). Uploading is very similar to uploading a regular HTML file or text file however, sometimes your FTP Client doesn't recognize the file type and therefore you must ensure you upload it in ASCII mode. There will be a setting in your FTP Client which you will allow this to be specified. Once you have set the upload mode to ASCII, then you can upload the file. Upload it to the /public_html or any directory within this.
An Example .htaccess file
For the following example we will change the default page from index.html (set by the server) to home.html
DirectoryIndex home.html
Yes, that is it. Just one line of code. Here is another example, setting a custom 404 error page:
ErrorDocument 404 /notfound.html
If you have any further questions, let us know as the Databloc support team are all experts at .htaccess files.
|
 |