You might have observed that you opened one URL, but were being redirected to another URL. Like when you try to open http://www.google.com/docs, you would be redirected to https://drive.google.com/#my-drive.
Sometimes it is necessary to do so due to various possible reasons as follows:
To show temporarily moved article with a hint that it has been moved temporarily
To show the content even if the URL is permanently moved through aliased URL
To display easily remembered URL
To add a trailing slash to make the website working fine if not configured properly on server side
To transfer URL from HTTP to HTTPS or vice versa according to the client's requirement
To display the domain name based on geolocation like typing
google.com
would redirect you to google.co.in if you are in India
Whichever the case may be, if you don't have any choice, go for the redirect option, else try to minimize it in your website.
If you have changed the content's URL recently using different rewrite engine rules or by any other way, try to fix the broken link, which will be a waste of time and we could lose users as well.
There are various ways to minimize or avoid redirects. Let's see how to avoid redirects as follows:
If you know the exact URL for any content, type that even though it is a bit lengthy. Trust me, it would save your time, and the response would be much faster because latency period while redirecting the URL is not present there. The worst thing about redirecting a URL is that unless and until it is being redirected properly it will not render anything, not even a single line of that page.
Sometimes a wrongly typed URL also redirects you to the correctly indented page like
http://www.facebook.net
would lead you to https://www.facebook.com/, so better type the correct URL, if possible.Try to type the forward slash (/) at the end of URL to render the default page properly like http://www.aliencoders.com/ to open the default page that is, http://www.aliencoders.com/index.html, which would otherwise give an error if it's not properly handled by the server. You may rewrite the rule to avoid redirect in such a case, so that the server automatically corrects the URL and serves the right resource for you.
Many websites use redirect to log the user's information for web analytics; if it is necessary or required, use some other method, such as sending a request through JavaScript, which should be negligible and the user would not notice the latency. For example:
img.src = "http://www.example.com/logs/small.gif?page = " + encodeURI(thisPage) + "&ref = " + encodeURI(referPage);
Now to avoid showing bad requests or repair broken links, it is quite obvious that URLs should be mentioned from time to time or article's reference would not work, because of a broken link, which may happen due to removal of such content or moving of such content somewhere else. We should check broken links and fix them, if we find any, from time to time. Top 'page not found' errors at www.aliencoders.com with the count is shown in the following screenshot:
When you pass any previously mentioned URLs for redirection, then it is either already mentioned at the server sided with the help of rewrite engine rule or it uses the http-equiv="refresh"
mechanism at the client side. As I always insist, try to avoid redirects; but if it is worthy to use redirects, use the server-side techniques to use redirects.
When you open any webpage, which is moved permanently or not available over the Internet, you would get either 404 (Not Found ) error or 410 (Gone) error as the server response. If you are not looking over these two issues seriously, you are surely playing with the user's emotions for which you have to pay by losing them permanently.
Wherever possible, you should update the links to resources that have moved, or delete those links if the resources have been removed. Avoid using HTTP redirects to send users to the requested resources, or to serve a substitute suggestion page. As previously described, redirects also slow down your site, and are better to avoid as much as possible. Use Google Analytics or any such famous analytics to track down all these errors to avoid it as much as possible.