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:
- In order to create this file, it is enough to use any available text editor (for example, notepad).
- Name (.htaccess) – without quotes and other things.
- Save the file.
- Then we transfer it to your server (hosting) using an FTP client, necessarily to the root directory of the site.
- 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:
- Always before starting to edit the .htaccess file save its working copy.
- Never add new rules to the working site without first checking the file.
- Encoding is usually UTF -8.
- Each rule needs to be written from a new line.
- Those instructions that are not processed by the Apache server are excluded – they immediately cause a server error.
- It is impossible to write several instructions in one line – the error 500 will be provided to you.
- 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:
- Setting 301 redirect on the site (common rule). Can be used for the necessary tasks.
- Server side hashing settings.
- Enable gzip compression (abbreviated from GNU Zip) – file compression on the server side.
- Secure the site: blocking ip addresses, bans and so on.
- 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.