Page 1 of 1

dead (changed) links in some blog posts

Posted: Fri Oct 16, 2015 12:17 am
by bryan
should be updated?

e.g. http://earlyretirementextreme.com/borso ... atrix.html

Code: Select all

<a href="http://forum.earlyretirementextreme.com/topic.php?id=1126">what would happen if everybody did it</a>
should be:

Code: Select all

<a href="http://forum.earlyretirementextreme.com/viewtopic.php?t=1126">what would happen if everybody did it</a>

Re: dead (changed) links in some blog posts

Posted: Fri Oct 16, 2015 6:13 am
by jennypenny
I don't think any of the links to forum posts work after the latest migration. It's a big job to fix them since there are probably hundreds of them scattered throughout the blog posts.

Re: dead (changed) links in some blog posts

Posted: Fri Oct 16, 2015 9:10 am
by chicago81
search and replace is a task that computers are terrific at automating ;)

Re: dead (changed) links in some blog posts

Posted: Fri Oct 16, 2015 4:17 pm
by jacob
Indeed. Unfortunately, this newfangled abstraction in which everything is about clicking the right box in some context menu is a bit beyond me. If my entire site was a bunch of html files, I'd fix this with awk outright. As it is (WP+SQL), it's too scary for me to contemplate considering the resulting shitstorm if I trip. (Whenever the site is down, I start getting emails within the hour ... it puts the pressure on ... :-P )

PS: Possibly this could be solved by a fancy httpaccess redirect?

Re: dead (changed) links in some blog posts

Posted: Sat Oct 17, 2015 2:42 am
by henrik
PS: Possibly this could be solved by a fancy httpaccess redirect?
Rewrite is probably a cleaner option.. something like this

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/topic.php?id=(.*)$ http://forum.earlyretirementextreme.com/viewtopic.php?t=$1 [R=301,L]
Unfortunately I don't have a place to test this at the moment, maybe someone else can try?

Of course, a more permanent solution would be an SQL query to replace all the old links with modified ones directly in the database
http://stackoverflow.com/questions/1252 ... in-a-field

Re: dead (changed) links in some blog posts

Posted: Sat Oct 17, 2015 5:21 am
by Quadalupe
@henrik: Agreed, I've done a lot of SQL updates at my previous job. It isn't that hard to do, but it is scary since you are directly working in the source Neo. Typically you can do something like this (I don't have a lot of experience with mysql, only with MSSQL, but it shouldn't differ a lot)

Code: Select all

BEGIN TRANSACTION

#find all the posts in which an old URL is used and display their ID's and content
SELECT post_id, content_field FROM post WHERE content_field LIKE '%topic.php?id=%'

#update the old URLS to the new ones
UPDATE post
SET content = REPLACE(content_field,'topic.php?id=','viewtopic.php?t=')
WHERE content_field LIKE '%topic.php?id=%'

#find all the posts in which an old URL is used and display their ID's and content
# this should return zero results, since we replaced all old URLS with new URLS.
SELECT post_id, content_field FROM post WHERE content_field LIKE '%topic.php?id=%'

# rollback all our work because we are scared to wreck things.
# if we want make these updates permanent, we use COMMIT instead of ROLLBACK
ROLLBACK 
Alternatively, you could write a query to update a single post and see how that goes. If you are satisfied with the result (i.e. the site didn't blow up), you can do it for all posts.

Or you could do a wordpress dump, search replace through the dump and reupload it (not sure how this works exactly).

Or you could do nothing, since I don't now how big of a problem it is right now.