How to make .htaccess file

The .htaccess (also known as Hypertext Access) file is a Web server configuration file that is used to control the behavior, security and performance of a site. Most webmasters create .htaccess file and use this file to control their sites and make sure everything is in good hands.

While there are many ways that you can configure your .htaccess file, the most common usage can be categorized into the following scenarios:

Authorization and authentication

The .htaccess file serves as a control to authorize and authenticate who can view your site (or certain page of the site). While you want your site to be visible to everyone, there may be times when it is visited by spambots and you start to receive many spam mails, comments, form submissions and so on. With the .htaccess file, you will be able to block access that comes from unauthorized sources (such as particular domain names or IP addresses).

Most used codes for generating .htaccess file are error 404 and error 403.

The simple and easy eay to build the .htaccess file is next one:

First, you edit the file:

 vi .htaccess

Once the file is edit, you can put:

ErrorDocument 403


ErrorDocument 404

Where “” is actually the domain where you want to send them.

If you are using some kind of Content Management System like WordPress you have to refer to the panel where you set up everything and either change the permalinks and in same time change .htaccess or install plugin to handle the changes for 404 pages.

Be the first to comment

Leave a Reply