• Cheap & Best Hosting

.htaccess Tutorial

This tutorial will explain what it is .htaccess and how it functions to maximize your website that are in Afiahost.com .

Although .htaccess is a file, but .htaccess can change the settings on the server and allow you to do many different things, as an example is to use .htaccess you can create your own 404 pages.
.htaccess is not difficult to use because they only need to put some simple instructions in a text file is then saved by name .htaccess

What is the use .htaccess?

Perhaps you are wondering what can be done by .htaccess, or maybe you’ve read about it but did not realize that many things you can do with .htaccess.

Here are some of functions .htaccess

* Mem-protected Folders / Protect Folder with password
* Transferring your website visitors with an automatic
* Create pages error display your own message
* Reject the visitors with a specific IP Address
* Change your file extension
* Only allow certain visitors with IP Address
* Allow / Reject list directory

Create .htaccess files

.htaccess file is a text file that has no name but has a length of 8 letter extension.
An easy way to create this file by creating a file ending in. Txt and then when you are finished making, you just need to twist them .htaccess

If you have trouble changing the name of the file you can change it to htaccess.txt and then upload the file to your hosting account. After the file uploads you can change the name to use an FTP program you have or use the File Manager you can access through your cpanel.

Creating own error message page

By using .htaccess you can create an error message page that can be used for your own website and no longer uses the default settings from the server.
By using their own error message page can make your site look more professional in handling errors that occur even allow you to create scripts that can tell you if an error occurred.

You can use your own error message as long as you know the code used (such as 404 for the page can not be found / page not found) by adding the command below into the file .htaccess you:

ErrorDocument code / file.html

For example if you have a file in the root directory notfound.html from your site and want to use it for 404, you can use the line below:

ErrorDocument 404 / notfound.html

If the file is not in the root directory of your website, you just need to add a directory structure in, for example:

ErrorDocument 404 / error / notfound.html

Here are common error messages:

401 – Authorization Required
400 – Bad request
403 – Forbidden
500 – Internal Server Error
404 – Wrong page

Then, all you have to do is create a file to display an error message when an error happens and upload those files, do not forget to upload also .htaccess file you.

How to restrict access to directories based on IP address using .htaccess file?

This method can be said is an effective way to protect the existing directory on a domain / site.
Folders other than those located inside the public_html folder can also be protected in the same way.
This method can only run if you have a hosting account with a static IP address itself.
Anyone who tried to visit the directory has been protected will get an error message 403 Forbidden error.

Steps to make:

* In the directory you want protected create or open .htaccess files.
* Place the code below and replace the existing 100 100 100 100 in this example with the IP Address you want to allow.

Order Deny, Allow
Deny from all
Allow from 100 100 100 100
* Additional: You can enter a portion of the IP Address, like, 100 100 100
* Additional: You can add other IP addresses separated by commas, like this

100 100 100 101, 100 100 100 102
* Save .htaccess and upload files .htaccess if you have not uploaded.

Permitting Directory Listing using .htaccess files

Here’s a way to allow your website visitors view the Directory Listing of your website:

* In the directory you want to allow directory listing, create or open .htaccess files.
* Place the code below.

Options + Indexes
* Save .htaccess and upload files .htaccess if you have not uploaded.

Notes: 1. AFIAHOST.com not recommend to do this in the root directory of your website.
2. To eliminate Directory Listing you can delete it or replace the line marked with a + sign -.

Using other than the index file on your website .*

By default, the first page of your website is the index .* files because the file is what will be the first time in search of your visitor’s browser so they visit your website.
But you may wish to change your website, to use a file name other than the index .*.

To do this fairly easily using .htaccess file and the command “301 Redirect”. Redirects are used to transfer the old website visitors to your website is new.

In this example you will be transferred to the file home.html:

* In the directory you want to allow directory listing, create or open .htaccess files.
* Place the code below.

Redirect 301 / index.html http://www.nameofdomainname.com/home.html
* Save .htaccess and upload files .htaccess if you have not uploaded.
* Test your work by visiting your website that is http://www.nameofdomainname.com, if successful, the address that appears will be http://www.nameofdomainname.com/home.html and display your website.

Domain Parking transferred on to another Domain

Having a different domain name for the same site is the ordinary thing.

To add these domains to the same website, many people use the services of “parked domains”, where when someone visits that domain will automatically open your website.
However in terms of search engine optimization, this is not the best thing to be done.

With search engines like Google as an example, you can lose the status ranking (PR) of your website because it has the same look for a different domain.
When Google search and view your site has the same content with different domain, then Google will count as plagiarism or the content of the website content and will automatically lose your PR status.
Domain Parking and the more you have, the greater the impact to the PR that you have.

If you put your website on a server that uses Apache, the negative effects of domain parking can be avoided by using mod_rewrite function.
The bonus of using this method is also the assignment by telling search engines that look the same in the domain parking has been moved to your website and does not disappear.
This means you will not be exposed to risk losing your PR status.

To do this redirect method, put the code below inside .htaccess files you:

RewriteEngine On
RewriteBase /
RewriteCond% (HTTP_HOST) ^ www.parkeddomain.com
RewriteRule ^(.*)$ http://maindomainname.com/ $ 1 [R = 301, L]

Domain parking If you have more than one or want to remove the “www.” of your domain, you only need to repeat the line “RewriteCond” for each domain parking that you have and without the www.

RewriteEngine On
RewriteBase /
RewriteCond% (HTTP_HOST) ^ www.parkeddomain1.com [OR]
RewriteCond% (HTTP_HOST) ^ parkeddomain1.com [OR]
RewriteCond% (HTTP_HOST) ^ www.parkeddomain2.com [OR]
RewriteCond% (HTTP_HOST) ^ parkeddomain2.com
RewriteRule ^(.*)$ http://maindomainname.com/ $ 1 [R = 301, L]

Domain Search