views:

127

answers:

3

I took over an old HTML based site with all hard coded links, no frames etc. Theres who knows how many pages that have a link to abc.html (<--example).

I've been asked to go through the pages and change the abc.html link to 123.html (<--another example).

I could download the entire site from via FTP then use find and replace to go through all the files, then upload the changes.

Problem is the site is poorly organized and heavily nested so theres probably several hundred mg of junk I'd have to download just to be sure.

The other option is to change the html code of abc.html and put in something like

We've moved, you are currently being redirected.

And use some sort of redirect.

Anyone have any other ideas on how to do this?

+2  A: 

Why not using a software such as Actual Search and Replace ?

marcgg
Looks like it would work, BUT, I'd have to mount the FTP server as a local directory
shaiss
Or download the files locally, yes. Is that a big issue?
marcgg
shaiss
+1  A: 

You will need to return HTTP 301 Moved Permanently on old links so that the search engines know that the content has moved and not just disappeared.

Developer Art
Thank you for the tip, I'll make a note of that.
shaiss
For SEO (Search Engine Optimization), you should do this as well.
Martin
A: 

I made a list of all the files that contained the old link using

grep -lir "some text" *

(above taken from comandlinefu.com)

I then used the following command to replace all the matching text accordingly.

find . -name '*.html' -exec sed -ir 's/old/new/g' {} \;

(also taken from commandlinefu.com)

I used the sed version as it created backups of the html files and named them *.htmlr

Not ideal as I now have more junk, but I can easily delete them with

rm *.htmlr
shaiss