How to redirect users to a different page.
If you want to redirect from a page that is still there, or is linked to from many external sources, here's some code that will redirect them. Whenever possible, use HTTP redirects. HTTP redirects tells the browser the new location of the file it is looking for by sending a [HTTP status code (3xx)]. Files that are no longer there should be removed or coded to send a HTTP status code 301 (moved permanently).
- If your server runs Apache and your server administrator has enabled [.htaccess], create a .htaccess file at the root directory with a line:
Redirect /oldpath http://server/newpath
For example, if we would like to make a redirect from http://www.unl.edu/webdevnet/abc.html to http://www.unl.edu/webdevnet/xyz.html, we would create a .htaccess at our directory root with the following line:
Redirect /webdevnet/abc.html http://www.unl.edu/webdevnet/xyz.html
- If your server has PHP enabled, you may use the PHP
header()function to make redirects.
<?php header("Location: http://www.unl.edu/webdevnet/xyz.php"); exit; ?>
- If none of those listed above are available, use this workaround.
Just replace 'http://www.unl.edu/' with the new URL.
- More examples and explanation can be found at http://www.w3.org/QA/Tips/reback