URL Redirects

You might want to redirect people to a different page when a page has been deleted, out of date, or if the page just doesn't exist any more. If you have a url that is easily miss spelled you can create redirect pages the will take the user to the correct page.

There are a view ways of redirecting a pages but we will only discuss two of them here

  1. Using the HTML Refresh meta tag
  2. Using the .htaccess file

Redirect using the HTML Refresh meta tag

The meta tag go's into the header of your document. Remember to change the page title, this is important for SEO. The meta tag look something like this

<META http-equiv="refresh" content="5;URL=http://www.zendfusion.com/newdirectory/or/page.html">
  1. You can even set a message that will display before the page is redirected. In this message you can for instance urge the viewer to update there bookmarks too the new URL with a notice that this page will be deleted in the near future.
  2. You can set a time delay to display the current page before redirecting by changing the 5 in the content=“5 section of the meta tag. In the above example the delay time is set to 5 seconds. If you want the page to redirect immediately, change the 5 to a zero 0
  3. Some browser does not support the REFRESH metatag so it is alway a good idea to put a link to the new page in the content section

Example

<html> 
  <head> 
   <title>Page deleted redirect to new page</title> 
   <META http-equiv="refresh" content="5;URL=//www.zendfusion.com/newdirectory/or/page.html"> 
  </head> 
  <body bgcolor="#ffffff"> 
    <center>
     The contents you are looking for have moved. You will be redirected to the new location automatically in 5      
     seconds. Please bookmark the correct page at <a href="http://www.zendfusion.com/newdirectory/or/page.html">
     http://www.zendfusion.com/newdirectory/or/page.html</a> 
    </center> 
  </body> 
</html> 

Redirect using the .htaccess file

Redirecting pages by using the .htaccess file you will have to create a command in the .htaccess file. This command

  1. can be broken up into 3 parts
    • the actual command
    • the URL to of the page that needs to be redirect
    • the URL to redirect too
  2. these three parts must be seporated by a single space and must all be on one line
  3. the directory to redirect too must be a full url even if it is on the same site.

Example

  redirect /directory/old_page.html http://www.zendfusion.com/new_directory/newpage.html

you can also direct an entire directory

redirect /old_dir/ http://www.zendfusion.com/new_dir/
 
/home/dodgydevil/wiki.zendfusion.com/data/pages/scripts/html/html_redirect.txt · Last modified: 2009/09/03 15:06 by bosbaba
[unknown button type]
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Zend Fusion