automatic redirection script for old pages?

  • nuflo
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: new york

Post 3+ Months Ago

hey all. anybody know of a script that i could put on the top of old pages to automatically open up my index page so old search engine links don't lead people to pages that have old dead links and missing images files? i don't want to delete them becuase the search engines have already crawled them and they come up in searched, i just want those pages to automatically revert to the index page. does such a think exist? and or is this wise?
thanks for any advice people of ozzu land!!
peace
ian
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

I just use a PHP file...

Code: [ Select ]
<?php
 header("HTTP/1.0 301 Moved Permanently");
 header("Status: 301 Moved Permanently");
 header("Location: http://www.yourdomain.com");
 exit;
?>
  1. <?php
  2.  header("HTTP/1.0 301 Moved Permanently");
  3.  header("Status: 301 Moved Permanently");
  4.  header("Location: http://www.yourdomain.com");
  5.  exit;
  6. ?>


Then just save it out as whatever your old file was called.

Of course, if you're using .html files, you can't put PHP code inside 'em (unless your host is configured to parse EVERYTHING for PHP code)...

But what you can do, is save the code above as error404.php

Then set it up as the default error document in .htaccess

Code: [ Select ]
ErrorDocument 404 /error404.php
  • nuflo
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: new york

Post 3+ Months Ago

i'll mess with it and see if i can make it work. thanks for the help!
peace
ian@nuflo
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

I use this code, works pretty quick.


Put this in the head section:
Code: [ Select ]
<script language="JavaScript">
<!--
function MM_goToURL() { //v2.0
 for (var i=0; i< (MM_goToURL.arguments.length - 1); i+=2) //with arg pairs
  eval(MM_goToURL.arguments[i]+".location='"+MM_goToURL.arguments[i+1]+"'");
 document.MM_returnValue = false;
}
//-->
</script>
  1. <script language="JavaScript">
  2. <!--
  3. function MM_goToURL() { //v2.0
  4.  for (var i=0; i< (MM_goToURL.arguments.length - 1); i+=2) //with arg pairs
  5.   eval(MM_goToURL.arguments[i]+".location='"+MM_goToURL.arguments[i+1]+"'");
  6.  document.MM_returnValue = false;
  7. }
  8. //-->
  9. </script>



And this in the HTML:
Code: [ Select ]
<body bgcolor="#FFFFFF" onLoad="MM_goToURL('parent','http://www.yourwebsiteaddress.com/');return document.MM_returnValue">
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

:D
Code: [ Select ]
<html><head>
<script language="javascript">
window.location="http://www.google.com";
</script>
</head></html>
  1. <html><head>
  2. <script language="javascript">
  3. window.location="http://www.google.com";
  4. </script>
  5. </head></html>
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

:roll:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

:D ASP
Code: [ Select ]
<%
Response.Redirect("http://www.google.com")
%>
  1. <%
  2. Response.Redirect("http://www.google.com")
  3. %>


Replace Google with your url of course, I just use it for examples and testing becouse it loads faster than just about anything.

I know, I tend to take all the fun out of things :roll:
  • musik
  • Legend
  • Super Moderator
  • User avatar
  • Posts: 6893
  • Loc: up a tree

Post 3+ Months Ago

oh lol fair enough :)
  • Vaclav
  • Born
  • Born
  • Vaclav
  • Posts: 2

Post 3+ Months Ago

In fact you do not need script, a meta will do:
<meta http-equiv="refresh" content="10;url=http://www.new.com">
Leave 10 secs for the redirect, otherwise search engines may spot this as a cloaking technique.

Best way is to use server redirect: 301 Moved Permanently.
  • nuflo
  • Novice
  • Novice
  • User avatar
  • Posts: 18
  • Loc: new york

Post 3+ Months Ago

you guys rock.
peace
ian@nuflo
  • LordArnell
  • Newbie
  • Newbie
  • LordArnell
  • Posts: 13
  • Loc: UK

Post 3+ Months Ago

I personally have used a javascript much as the same as above especially when a group was referencing a file on my site that I had renamed and had to create some new pages just the redirection. I would leave these pages about a month or two and then remove since most search engines rescan your site every month.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 73 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.