Changed Domain Name. Change internal links in posts?

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Suggested Hosts
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

I'm sure I've read the answer to this question before, but I've searched a LOT and cannot find it now. So please excuse me for asking it again if it has been asked before.

I've changed the domain name of my forums site (with the old domain name still redirecting to the new one). One day the redirection from the old domain name will be disabled at which point all the in-post links to other forum topics will stop working. So I need to update the database to change the post_text field in the posts table.

I'm testing this on my testing service first, and I can get it to work for some of the text, but not the text in URL BBCode tags. Here's what I've got in my test post:

Code: Select all

This is a test.  Please ignore.

Direct URL http://bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080
Direct URL post http://www.bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080

Between URL tags  [url]http://bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080[/url]
Between URL tags  [url]http://www.bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080[/url]

Inside URL tags  [url=http://bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080]Flying Toilets[/url]
Inside URL tags  [url=http://www.bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080]Flying Toilets[/url]
Here's the SQL I run:

Code: Select all

UPDATE phpbb3_posts SET post_text = replace( post_text, "bushwalk-tasmania.com", "tasmania.bushwalk.com" ) ;
Here's what the test post looks like afterwards:

Code: Select all

This is a test.  Please ignore.

Direct URL http://tasmania.bushwalk.com/forum/viewtopic.php?f=3&t=3080
Direct URL post http://www.tasmania.bushwalk.com/forum/viewtopic.php?f=3&t=3080

Between URL tags  [url]http://bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080[/url]
Between URL tags  [url]http://www.bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080[/url]

Inside URL tags  [url=http://bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080]Flying Toilets[/url]
Inside URL tags  [url=http://www.bushwalk-tasmania.com/forum/viewtopic.php?f=3&t=3080]Flying Toilets[/url]
As you can see, the first pair get updated fine, but the second two pairs (using BBCode's URL tags) do not get updated.

What is the comprehensive method of updating all links and references within all posts to point to the new domain name?

(of course it would be nice if when submitting a post, phpBB would detect same-domain links and convert them to relative links to avoid occurring in the first place) :-)
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Re: Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

PS. I note that in the database, the post_text field contains the following:

Code: Select all

This is a test.  Please ignore.

Direct URL <!-- m --><a class="postlink" href="http://tasmania.bushwalk.com/forum/viewtopic.php?f=3&t=3080">http://tasmania.bushwalk.com/forum/view ... f=3&t=3080</a><!-- m -->
Direct URL post <!-- m --><a class="postlink" href="http://www.tasmania.bushwalk.com/forum/viewtopic.php?f=3&t=3080">http://www.tasmania.bushwalk.com/forum/ ... f=3&t=3080</a><!-- m -->

Between URL tags  [url:2tfsk6zo]http&#58;//bushwalk-tasmania&#46;com/forum/viewtopic&#46;php?f=3&t=3080[/url:2tfsk6zo]
Between URL tags  [url:2tfsk6zo]http&#58;//www&#46;bushwalk-tasmania&#46;com/forum/viewtopic&#46;php?f=3&t=3080[/url:2tfsk6zo]

Inside URL tags  [url=http&#58;//bushwalk-tasmania&#46;com/forum/viewtopic&#46;php?f=3&t=3080:2tfsk6zo]Flying Toilets[/url:2tfsk6zo]
Inside URL tags  [url=http&#58;//www&#46;bushwalk-tasmania&#46;com/forum/viewtopic&#46;php?f=3&t=3080:2tfsk6zo]Flying Toilets[/url:2tfsk6zo]
Is it then safe to run something like:

Code: Select all

UPDATE phpbb3_posts SET post_text = replace( post_text, "bushwalk-tasmania&#46;com", "tasmania&#46;bushwalk&#46;com" ) ;
Will this achieve what I want safely?
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Re: Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

OK... that seems to have worked in the testing environment.

It appears that I've answered my own question. However, I really dislike hacking around in the database, and would be grateful for some assurance from others who've done it the same way if they could let me know if they had any problems or not. Or from phpBB people to say, "yes, this is the officially supported method".
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 52794
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve

Re: Changed Domain Name. Change internal links in posts?

Post by stevemaury »

Backup the posts table first.

Magic urls (ones that go hot without [URL] tags) appear in the posts_text like this:

Code: Select all

http://www.old_domain.com
Those in the [URL] tags appear like this:

Code: Select all

http&#58;//www&#46;old_domain&#46;com
So, this query will fix both types:

Code: Select all

update phpbb_posts set post_text = replace(post_text, 'www.old_domain.com', 'www.new_domain.com');
update phpbb_posts set post_text = replace(post_text, 'www&#46;old_domain&#46;com', 'www&#46;new_domain&#46;com');
It may be necessary to then reparse the BBCode using the Support Toolkit - http://www.phpbb.com/files/support/stk_ ... .0-RC3.zip
I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Re: Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

stevemaury wrote:Backup the posts table first.

Magic urls (ones that go hot without [URL] tags) appear in the posts_text like this:

Code: Select all

http://www.old_domain.com
Those in the [URL] tags appear like this:

Code: Select all

http&#58;//www&#46;old_domain&#46;com
So, this query will fix both types:

Code: Select all

update phpbb_posts set post_text = replace(post_text, 'www.old_domain.com', 'www.new_domain.com');
update phpbb_posts set post_text = replace(post_text, 'www&#46;old_domain&#46;com', 'www&#46;new_domain&#46;com');
OK, so that confirms what I'd figured out and wrote above. Thanks for this - I'm grateful for the reassurance.
It may be necessary to then reparse the BBCode using the Support Toolkit - http://www.phpbb.com/files/support/stk_ ... .0-RC3.zip
This is a bit vague and confusing and raises a few more question. What do you mean 'may'? Under what circumstances is this 'reparse' necessary? How do I determine if a 'reparse' is necessary or not?

If it turns out that a reparse is necessary, then does this mean that it is not possible to complete a domain name transition without installing additional software? Ie, it is not possible to complete a domain name transition in phpBB with just the phpBB package?
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Re: Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

PS. What does the 'reparse' actually do? I found this page, but all it says is...

Reparse BBCode: Reparses the BBCode for the boards posts.

Is it something to do with the cryptic bit of text that appears to be stored in each BBCode tag? Is this cryptic text somehow checksummed against the rest of the tag? I'm just guessing, as this is all a mystery to me. :-)

PPS. I've installed the support toolkit and am running the "Reparse BBCode" in any case, just to be on the safe side. I thought when it said that step 1 was complete and step 2 would be done soon that it was half way through. Boy was I wrong. It's currently up to step 60 and still going. How many steps are there?
Son of a Beach
Registered User
Posts: 294
Joined: Fri Sep 07, 2007 1:36 am
Location: Tasmania

Re: Changed Domain Name. Change internal links in posts?

Post by Son of a Beach »

Son of a Beach wrote:I've installed the support toolkit and am running the "Reparse BBCode" in any case, just to be on the safe side. I thought when it said that step 1 was complete and step 2 would be done soon that it was half way through. Boy was I wrong. It's currently up to step 60 and still going. How many steps are there?
ah... finally done... about 70 steps, it seems

Return to “[3.0.x] Support Forum”