Server-side redirects: Introduction to .htaccess file
First, htaccess (Hypertext Access) is a batch file locates in Apache HTTP server. It is also referred to as “distributed configuration files”, it provides a way to make configuration changes on a directory. A file containing one or more configuration directives is placed in a particular document directory. Guidelines apply to that directory and all sub directories of it.
There is a wide range of tasks that .htaccess can manage websites, including: custom error pages, password protection/authorization for a specific directory, allowing SSI (server-side includes), blocking of users per IP, blocking bad bots, changing default pages directory This prevents a directory listing, and adding redirects MIME types.
The best way to redirect old or dead links is to use the server-side redirects. Most often url redirect is implemented by the help of htaccess and meta tag. Most Web servers use .htaccess to facilitate this process. It’s pretty simple to edit and perform a number of tasks.
The important thing is not to delay the user because they are impatient. Nobody likes to wait for a page to load and a “page unavailable” result that lose the visitor.
The usual way and the fastest server-side redirects before were to add an HTTP refresh. Search engines are not too fond of this code and this page may be removed from the index of the search engine. This is something you definitely do not want to be a company or freelance. Usually this occurs if you use a drink for less than 10 seconds.
How can you use .htaccess for Custom Error Pages?
Here are some common uses of the file .htaccess. These allow you to have your own personal error pages (such as when a file is not found) instead of error pages of your host or not to have the page. This will make your site seem much more professional in the unlikely event of an error.
It will also allow you to create scripts to notify you if there is an error. For example, you can create a JSP script on your own website to automatically e-mail when a page is not found.
You can use custom error pages for any error as long as you know its number (like 404 for page not found, 403 to 500 and banned for internal server error) by adding the following codes into your htaccess file:
ErrorNumber ErrorDocument / path / file.html
For example, if I had the not_found.html file in the /errors on my site and I wanted to use it for a 404 I would use:
ErrorDocument 404 / errors / not_found.html
Another example is that if I had a JSP script which will automatically send a notification by e-mail when an internal server error occurred on my site, and I put the script in the path: / utility / mailer.jsp, I would use:
ErrorDocument 500 / utility / mailer.jsp
In addition, you can use an external page to customize your error. For example, when you are getting a 404 Not Found page on Yahoo, and you wrote the URL: http://www.infoheaps.com/use-webcam-to-purchase-online/, you should change your content of .htaccess as follows:
Http://ErrorDocument 404 http://www.infoheaps.com/use-webcam-to-purchase-online/
With this code, when a bad request comes to your website, it will be sailed http://www.infoheaps.com/use-webcam-to-purchase-online/