MyBB Community Forums

Full Version: Update internal thread links after domain change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

recently I moved my forum from http://forums.domain1.com to http://forums.domain2.com. Everything works fine, except for a thing: internal thread links are broken.

Users like to link between threads. For example in the thread http://forums.domain1.com/thread-82342.html is a link to the thread http://forums.domain1.com/thread-82547.h...ght=update.

Those thread links are no relative, but absoulte links. But this is a problem because after I moved my forum from forums.domain1.com to forums.domain2.com the thread links stay the same and still link to the old domain, which obviously reports a 404 error.

How can I update my database to fix broken links? Two days ago I found a site where another user posted a mysql query from MattRogowski to deal with this problem. But I can't find the link to the page anymore. It was some 'UPDATE ... SET VALUES ... WHERE ...' code, where string matching is used to find and update thread links pointing to the old domain.
UPDATE `mybb_posts` SET `message` = REPLACE(message, 'http://forums.domain1.com', 'http://forums.domain2.com');

Please backup your posts table before doing this though.
Might even have to do that without http:// in front, and if you no longer own domain1.com maybe even without forums. in front...
(2010-11-30, 10:34 AM)MattRogowski Wrote: [ -> ]
UPDATE `mybb_posts` SET `message` = REPLACE(message, 'http://forums.domain1.com', 'http://forums.domain2.com');

Please backup your posts table before doing this though.

This is the I was looking for. Thanks Matt!