Redirecting
Category: Internet Tips | Date: 2002-12-12 |
Virtually all webmasters will come up against a real problem during their careers. They will discover that not all links to their site wind up where they were intended.
What happens? Using my own site as an example, an author created an article and used one of my works as a reference. He linked to the page, but spelled it incorrectly. This resulted in a 404 error, which I discovered by examining the server log files.
Another common occurrence is site reorganizations. As you move files around, rename them or even delete them entirely, you will find visitors getting 404 errors. This is because other sites, search engines and directories often link to those pages. As much as you try you will not be able to change all of these links.
Additionally, you might move your site to another domain. If you just close down your old site you may lose the visitors that had the old URL altogether.
If you don't do anything at all about kind of thing you will lose visitors. It's hard to get listed in search engines and directories, and it takes time to convince people to bookmark your pages and add them to their link directories on their own sites. It's a shame to lose the benefits simply because a page doesn't exist.
You can do some things to keep that traffic. To begin, be sure you own your own domain name. Do this regardless of where your site is hosted (free or paid hosts), because then if you move your links move with you.
If your host allows, create a 404 error page. This at least allows you to direct your poor lost visitors back to your site. You can put a menu and even a search box on that page, which serves to pull visitors who get page not found errors back into your site.
Now keep an eye on your server logs. If you determine that someone has linked to a non-existent page, then make a note of it. This is especially true if you are getting a lot of hits from a site. I once got mentioned in an article in which the author misspelled the page name (he put .html and my page ended with .htm). I was receiving hundreds of hits per hour, all lost because it didn't go to the right page.
Also make a note if you rename, delete or move a page. You will want to ensure that anyone who links to those pages get directed to the new page (or to an index if you deleted the page).
How do you recapture the traffic to these lost pages? There are several things you can do.
Most people use a special meta tag called "refresh" to direct their visitors to the new page. To do this you create a blank page which contains this tag (it is placed in the header). The tag simply says "wait a few seconds then go to a named page".
This example waits one second, then loads the specified page into the browser.
If you do this, it's a good idea to wait at least 30 seconds and to include a link so the user can click if the browser does not go to the new URL for some reason.
You should note that according to the W3C organization (one of the web's top standards groups) "Some user agents support the use of META to refresh the current page after a specified number of seconds, with the option of replacing it by a different URI. Authors should NOT use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects."
There are many ways to do server-side redirects. One of the most common is to use the .htaccess file, which is supported by the Apache web server. .htaccess supports a directive called redirect. This directive transparently changes the URL to a new URL. The visitor never sees anything, never even knows he moved to a new website. It happens immediately. The URL in the address bar does change, but that's it. You basically tell Apache "if you see this URL, change it to this one here". There is no page, no link, nothing like that.
Do all hosts support .htaccess? No they don't. It has to be enabled. Many hosts do not allow this command due to security concerns. In my experience, though, virtually all paid apache hosts which allow user written CGI also allow .htaccess. It would be a good idea to make sure before paying them, though, if you need the functions it supports.
There are other server-side redirection tricks. You can use special ASP, PHP, SSI or even CGI commands to move the user to a new page.
For links internal to my own web site, I generally use both methods. I create a .htaccess entry directing the visitor to the new page and also create a blank meta-tag redirection page. The meta-tag page includes a link to the new page as well.
Why go through this trouble? The server-side redirect will always be executed first if the host supports server site redirects. However, hosts do close up shop occasionally (especially these days) and you might be forced to move. If your new host does not support server-side redirection for some reason, then your meta-tag pages will be used instead.
If I moved a site, I would use a meta redirect with a 60 second delay. For example, if I had a page on geocities (ugh) and moved it to my own domain, I would leave a meta redirect page at geocities (even if it supported .htaccess, which it does not), because I want to tell my visitors to change their bookmarks. You must be careful to include a link to click on just in case the browser does not redirect (I think a user can turn this off somehow in some setting somewhere).
About the Author
Richard Lowe Jr. is the webmaster of Internet Tips And Secrets. This website includes over 1,000 free articles to improve your internet profits, enjoyment and knowledge.
Web Site Address: internet-tips.net
Weekly newsletter: http://www.internet-tips.net/joinlist.htm
Daily Tips: internet-tips@GetResponse.com
Claudia Arevalo-Lowe is the webmistress of Internet Tips And Secrets and Surviving Asthma. Visit her site at http://survivingasthma.com
List of articles available for reprint: article-list@internet-tips.net
articles@internet-tips.net
http://www.internet-tips.net
What happens? Using my own site as an example, an author created an article and used one of my works as a reference. He linked to the page, but spelled it incorrectly. This resulted in a 404 error, which I discovered by examining the server log files.
Another common occurrence is site reorganizations. As you move files around, rename them or even delete them entirely, you will find visitors getting 404 errors. This is because other sites, search engines and directories often link to those pages. As much as you try you will not be able to change all of these links.
Additionally, you might move your site to another domain. If you just close down your old site you may lose the visitors that had the old URL altogether.
If you don't do anything at all about kind of thing you will lose visitors. It's hard to get listed in search engines and directories, and it takes time to convince people to bookmark your pages and add them to their link directories on their own sites. It's a shame to lose the benefits simply because a page doesn't exist.
You can do some things to keep that traffic. To begin, be sure you own your own domain name. Do this regardless of where your site is hosted (free or paid hosts), because then if you move your links move with you.
If your host allows, create a 404 error page. This at least allows you to direct your poor lost visitors back to your site. You can put a menu and even a search box on that page, which serves to pull visitors who get page not found errors back into your site.
Now keep an eye on your server logs. If you determine that someone has linked to a non-existent page, then make a note of it. This is especially true if you are getting a lot of hits from a site. I once got mentioned in an article in which the author misspelled the page name (he put .html and my page ended with .htm). I was receiving hundreds of hits per hour, all lost because it didn't go to the right page.
Also make a note if you rename, delete or move a page. You will want to ensure that anyone who links to those pages get directed to the new page (or to an index if you deleted the page).
How do you recapture the traffic to these lost pages? There are several things you can do.
Most people use a special meta tag called "refresh" to direct their visitors to the new page. To do this you create a blank page which contains this tag (it is placed in the header). The tag simply says "wait a few seconds then go to a named page".
This example waits one second, then loads the specified page into the browser.
If you do this, it's a good idea to wait at least 30 seconds and to include a link so the user can click if the browser does not go to the new URL for some reason.
You should note that according to the W3C organization (one of the web's top standards groups) "Some user agents support the use of META to refresh the current page after a specified number of seconds, with the option of replacing it by a different URI. Authors should NOT use this technique to forward users to different pages, as this makes the page inaccessible to some users. Instead, automatic page forwarding should be done using server-side redirects."
There are many ways to do server-side redirects. One of the most common is to use the .htaccess file, which is supported by the Apache web server. .htaccess supports a directive called redirect. This directive transparently changes the URL to a new URL. The visitor never sees anything, never even knows he moved to a new website. It happens immediately. The URL in the address bar does change, but that's it. You basically tell Apache "if you see this URL, change it to this one here". There is no page, no link, nothing like that.
Do all hosts support .htaccess? No they don't. It has to be enabled. Many hosts do not allow this command due to security concerns. In my experience, though, virtually all paid apache hosts which allow user written CGI also allow .htaccess. It would be a good idea to make sure before paying them, though, if you need the functions it supports.
There are other server-side redirection tricks. You can use special ASP, PHP, SSI or even CGI commands to move the user to a new page.
For links internal to my own web site, I generally use both methods. I create a .htaccess entry directing the visitor to the new page and also create a blank meta-tag redirection page. The meta-tag page includes a link to the new page as well.
Why go through this trouble? The server-side redirect will always be executed first if the host supports server site redirects. However, hosts do close up shop occasionally (especially these days) and you might be forced to move. If your new host does not support server-side redirection for some reason, then your meta-tag pages will be used instead.
If I moved a site, I would use a meta redirect with a 60 second delay. For example, if I had a page on geocities (ugh) and moved it to my own domain, I would leave a meta redirect page at geocities (even if it supported .htaccess, which it does not), because I want to tell my visitors to change their bookmarks. You must be careful to include a link to click on just in case the browser does not redirect (I think a user can turn this off somehow in some setting somewhere).
About the Author
Richard Lowe Jr. is the webmaster of Internet Tips And Secrets. This website includes over 1,000 free articles to improve your internet profits, enjoyment and knowledge.
Web Site Address: internet-tips.net
Weekly newsletter: http://www.internet-tips.net/joinlist.htm
Daily Tips: internet-tips@GetResponse.com
Claudia Arevalo-Lowe is the webmistress of Internet Tips And Secrets and Surviving Asthma. Visit her site at http://survivingasthma.com
List of articles available for reprint: article-list@internet-tips.net
articles@internet-tips.net
http://www.internet-tips.net
Copyright © 2005-2006 Powered by Custom PHP Programming