How to create a .htaccess file
If you have your own website, sooner or later you will have to face the creation of the .htaccess file. There are many descriptions of this file, various functions, and everything that can be done with it on the network. But for some reason no one wants to tell how exactly to create it.
Most often, when .htaccess is uploaded to the server or created there, visitors instead of the site see a 500 error. The problem is that the file must be in UNIX format. I’ll try novice users step by step to show how to create .htaccess
For work, we need Notepad ++ v4.7.5 notebook program. It is free, so download it (without any problems) from the official website of the developer and install it.
First, I wanted to create this file to direct visitors typing the address of a nonexistent or deleted page to the main page of my site. For example, you can type in the browser line http://www.wikispace.ru/ any phrase and you will still be taken to the main page. For this function to work in the .htaccess file, write
ErrorDocument 404 http://www.wikispace.ru
Where wikispace is the name of your site
Let’s go 🙂 We start the Notepad 4.7.5 program, at the top left, click on the _new file tab. In the program window, write
ErrorDocument 404 http://www.wikispace.ru (change the site address to yours)
Next, go to the “encoding” tab with one click, convert to unix format
Visually, everything will remain the same. No more actions, just close the program and respond to the request for saving
In the window that appears, select the location to save, enter the name of the file necessarily (dot) htaccess
The file type is left All types (*. *)
Now such a file can be uploaded to the server, to the root folder (directory) of the site and all the lost visitors will be yours. To check, type the address of your resource in the browser, if the error is 500, it means that you did something wrong. Delete the file and repeat the procedure how to create .htaccess again, be more careful. If everything went smoothly, type the address of a non-existent page, you will have to get to the main page of the site. If you wish, you can prescribe deeper settings: password protection of directories, redirection to another address, PHP execution in HTML, etc., there are a lot of settings, and there are a lot of information on the network, just experiment with caution. And I wish you good luck in your endeavors.