Changing Links throughout 20 thousand Posts

Dec 9, 2010
75
0
0
Sunnyvale
Hey guys;

I have a problem I am trying to solve. I recently bought a site that was 20, 000 pages of amazon book reviews which have a review followed by a youtube video and then a amazon link and image of the book which just link to these amazon products but without any referral id. I was curious if there is a way a programmer or something could make those links redirect with my amazon associates id within them? Or at worst maybe I could find a way to redirect every amazon id within the site to my amazon assoicates affiliate page just linked directly to the books homepage?

Any suggestions?
 


Yes, quite simple actually....

A) If using a MySQL Database: download the .sql file open it with Notepad++ do a find and replace for {id#} with {yourid#}.

B} If static html/php download all files and do a find and replace. I recommend using Notepad++ makes this task very quick and will allow you to work with a large number of files at once.
 
Probably easier to use mod_rewrite to rewrite the links, will save you having to edit any of the site and quite easy to do.
 
Yes, quite simple actually....

A) If using a MySQL Database: download the .sql file open it with Notepad++ do a find and replace for {id#} with {yourid#}.
Problem with this solution is that there is no amazon associate id's to replace. Basically they are all direct links to the products.

Any suggestions? Do you guys think that there is any kind of wordpress redirection plugin that would just allow me to forward any urls containing amazon.com to my referral url?
 
gutter, pretty sure mod_rewrite just translates incoming requests; it won't change links inside the content of a response on the fly (as far as i know anyway).

sounds like you need to mass search and replace with a tool that has some regex or pattern matching abilities.

or you could include some javascript on every page that changes the amazon links on the fly. i kinda like that idea because presumably google wouldn't see them as affiliate links.

do you know how to do the translation from the current format to the correct affiliate link format? is it as simple as adding a querystring parameter?
 
Yeah mod_rewrite isn't going to do the job. These are outgoing links direct to Amazon.

If they're individual pages, you could create a PHP script to go through each file and replace the link. If it's a DB then you can do what someone else suggested.

If you could post a few of the current links and what they would be changed to, that would give us a better idea.

I think you could do it with javascript. But it wouldn't be a very neat solution.
 
Why are ya'll suggesting that he download the SQL file? Just find/replace inside each post field. It's much less prone to rogue replaces.

Code:
UPDATE tableName 
SET fieldName = replace(fieldName, 'String of Text To Replace', 'String of Text You Want To Insert');

Just add a WHERE clause if you want to restrict any changes to specific rows.

So, say you had this iPad Stylus, you'd run that query and do a find for the URL, and replace with your affiliate information after it and the redirect information before it.

So you'd end up with something like this:
Code:
http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http://www.amazon.com/Acase-2nd-Generation-Capacitive-Stylus/dp/B004HBK4T0/ref=sr_1_24?s=wireless&ie=UTF8&qid=1307982883&sr=1-24&tag=amazonIDGoesHere&linkCode=ur2&camp=1789&creative=9325
 
Why are ya'll suggesting that he download the SQL file? Just find/replace inside each post field. It's much less prone to rogue replaces.

Code:
UPDATE tableName 
SET fieldName = replace(fieldName, 'String of Text To Replace', 'String of Text You Want To Insert');
Just add a WHERE clause if you want to restrict any changes to specific rows.

So, say you had this iPad Stylus, you'd run that query and do a find for the URL, and replace with your affiliate information after it and the redirect information before it.

So you'd end up with something like this:
Code:
http://www.amazon.com/gp/redirect.html?ie=UTF8&location=http://www.amazon.com/Acase-2nd-Generation-Capacitive-Stylus/dp/B004HBK4T0/ref=sr_1_24?s=wireless&ie=UTF8&qid=1307982883&sr=1-24&tag=amazonIDGoesHere&linkCode=ur2&camp=1789&creative=9325

This^^.

Don't download and upload. Just go into PHPMyAdmin and run the query. I do recommend a backup beforehand, just to make sure nothing gets messed up by accident.

Hope this helps.
 
Problem with this solution is that there is no amazon associate id's to replace. Basically they are all direct links to the products.

Any suggestions? Do you guys think that there is any kind of wordpress redirection plugin that would just allow me to forward any urls containing amazon.com to my referral url?
Are these links inside of a PHP/HTML PAGE, or are they being pulled from a Database? what is an example link format (ie, post a link so that i can SEE it's structure). Also, are you using Linux? If so, this will be MUCH easier.
 
Hey guys;

I have a problem I am trying to solve. I recently bought a site that was 20, 000 pages of amazon book reviews which have a review followed by a youtube video and then a amazon link and image of the book which just link to these amazon products but without any referral id. I was curious if there is a way a programmer or something could make those links redirect with my amazon associates id within them? Or at worst maybe I could find a way to redirect every amazon id within the site to my amazon assoicates affiliate page just linked directly to the books homepage?

Any suggestions?

If on wordpress use the search and replace pplugin, then have every amazon url replaced with your affiliate link