How to create a .htaccess file – detailed instructions for beginners

How to create a .htaccess file – detailed instructions for beginners

How to create a new .htaccess file? The .htaccess file, as a rule, has only an extension under Unix – system. And it benefits sites running the Apache server. Htaccess has a set of rules for a specific site on the server, which Apache server executes while the site is running. Thanks to him, you can specify a significant number of useful rules for the site.

Instructions for creating .htaccess file:

  1. In order to create this file, it is enough to use any available text editor (for example, notepad).
  2. Name (.htaccess) – without quotes and other things.
  3. Save the file.
  4. Then we transfer it to your server (hosting) using an FTP client, necessarily to the root directory of the site.
  5. Then you can edit it as you like, but you must update the version of the file on the server (hosting).

Features of the .htaccess file settings and common errors

So, this file most often causes a banal server error  500 Internal Server Error . Edit the file must be very careful and follow the following rules:

  1. Always before starting to edit the .htaccess file save its working copy.
  2. Never add new rules to the working site without first checking the file.
  3. Encoding is usually UTF -8.
  4. Each rule needs to be written from a new line.
  5. Those instructions that are not processed by the Apache server are excluded – they immediately cause a server error.
  6. It is impossible to write several instructions in one line – the error 500 will be provided to you.
  7. Be careful – an extra space or character can lead to an error.

What effect does the .htaccess file have on the site?

As a rule, thanks to this file, you can optimize the site for search engines. Here is what he can:

  1. Setting 301 redirect on the site (common rule). Can be used for the necessary tasks.
  2. Server side hashing settings.
  3. Enable gzip compression (abbreviated from GNU Zip) – file compression on the server side.
  4. Secure the site: blocking ip addresses, bans and so on.
  5. Specify the required amount of memory allocated for the site.

This is the minimum available functionality for this file. The main thing is to follow all these recommendations. In the following articles, I will try to describe some of the rules for this file.

Leave a Reply

Close Menu