Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Smart Forwarding Script upon 404

by zane (Acolyte)
on May 13, 2001 at 15:39 UTC ( #80021=perlquestion: print w/replies, xml ) Need Help??

zane has asked for the wisdom of the Perl Monks concerning the following question:

I'm in the process of transferring a bunch of content from one website to another, and when I'm done, I want to make a script which will automatically forward users from the old website to the new, and not only that, but to the piece of content that they were trying to access on the old server.

I'm currently thinking I'll do it this way:

  1. remove all of the content from the old site
  2. make the 404 file not found errordoc file point at a CGI script
  3. that 404.pl script will look at the filename they were trying to access, and do a fuzzy lookup of it in a hash of all the filenames in the new website's document tree.
  4. If there's a perfect match, then they'll just be forwarded seamlessly, if there are several matches, they'll get the list, along with the text fromt he DESCRIPTION meta-tag in the file
This seems like such a useful thing, that I am suspicious it may have already been written. I haven't been able to find it though. Does anyone know if it exists? Does anyone have suggestions for making it work better, or see problems with the idea?

It would also work well for correcting typos or making broken links work, within a site. e.g. I move a file to a new directly, but forget to update some of the links. Someone follows the one of the old links, and, since the file still has the same name, the 404.pl script finds it and instantly forwards them, and they never see an error. (If it works, this could lead to great laziness on my part...)

Replies are listed 'Best First'.
Re: Smart Forwarding Script upon 404
by thpfft (Chaplain) on May 13, 2001 at 16:08 UTC
Re: Smart Forwarding Script upon 404
by merlyn (Sage) on May 13, 2001 at 20:46 UTC
Re: Smart Forwarding Script upon 404
by Anonymous Monk on Jun 06, 2001 at 05:52 UTC

    You might want to check out www.aplawrence.com/Unix/custom404.html

    I found it while looking for a solution to a similar problem of my own. I just took over maintainance of a web site which was previously done by several different people (all in their own areas). Needless to say, the site is a mess, so my first task is to clean it up and reorganize it.

    Since I'll need to move a lot of files around, I didn't want to set up a ton of individual links for each page I move. So, I started working on a script (run on every 404 error) that would search through a text file, listing the pages that have been moved. This way, I can just keep this one file up to date.

    While working on this, I found had some ideas to extend this to random 404s. I wanted the program to be able to correct any mispelled urls and give a list of possible matches (if the page was not found in the moved file).

    I'm still working on the script (with much help from the page above). But I should be done with it by the end of this week. When I get it finished, I'll put up another post (since I want to have everyone look through it and comment on it anyway).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://80021]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2021-09-18 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?