dead (changed) links in some blog posts

Questions and comments
Post Reply
User avatar
bryan
Posts: 641
Joined: Sat Nov 29, 2014 2:01 am
Location: mostly Bay Area

dead (changed) links in some blog posts

Post by bryan » Fri Oct 16, 2015 12:17 am

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>

User avatar
jennypenny
Posts: 5191
Joined: Sun Jul 03, 2011 2:20 pm
Location: Stepford USA

Re: dead (changed) links in some blog posts

Post by jennypenny » Fri Oct 16, 2015 6:13 am

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.

chicago81
Posts: 253
Joined: Sat Feb 04, 2012 3:24 pm
Location: Chicago, IL

Re: dead (changed) links in some blog posts

Post by chicago81 » Fri Oct 16, 2015 9:10 am

search and replace is a task that computers are terrific at automating ;)

jacob
Site Admin
Posts: 8952
Joined: Fri Jun 28, 2013 8:38 pm
Location: USA, Zone 5b, Koppen Dfa, Elev. 620ft, Walkscore 73
Contact:

Re: dead (changed) links in some blog posts

Post by jacob » Fri Oct 16, 2015 4:17 pm

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?

henrik
Posts: 707
Joined: Fri Apr 13, 2012 5:58 pm
Location: EE

Re: dead (changed) links in some blog posts

Post by henrik » Sat Oct 17, 2015 2:42 am

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

Quadalupe
Posts: 57
Joined: Fri Jan 23, 2015 4:56 am
Location: the Netherlands

Re: dead (changed) links in some blog posts

Post by Quadalupe » Sat Oct 17, 2015 5:21 am

@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.

Post Reply