XF 2.1 Internal links - convert XF1 "page-x#" links to XF2 "post-" links?

Bimble

Active member
In XF1 internal links included the page number the post was on, e.g.: /threads/thread-title.123456/page-3#post-5249947

Unfortunately this page number changes if you delete a good number of earlier posts in the thread, or if you change the number of posts displayed per page, resulting in lots of broken links all over the site.

XF2 cures this problem by removing the page number from the URL and linking directly to the post number - great!! (y) (y) (y)

As we work through our planning and testing for upgrading to XF2 we wondered if there was a way to (post upgrade) convert the old XF1 links that have the page number in, to XF2 links that directly reference the post.

Maybe some sort of query that finds links with page- in them and removes it?

Any thoughts, ideas, or even MySQL query examples we might use to achieve this would be very welcome. Thank you.
 
Could someone please check the query below and confirm it'll remove the page-2# part - but, only for links with our site domain?

Code:
UPDATE `xf_post` SET `message` = replace(message, 'page-2#', '') WHERE `message` LIKE '%https://www.oursitedomain.com%'
 
I'd like to know of a fix too on this. Did you manage to get it sorted?

I've recently upgraded from XF1.5 to XF2 and also changed the posts per page setting I now see users reporting links within the forums are broken because the original page numbers within the URLs are now not correct.

Does anyone have a fix?
 
Could someone please check the query below and confirm it'll remove the page-2# part - but, only for links with our site domain?

Code:
UPDATE [ICODE]xf_post[/ICODE] SET [ICODE]message[/ICODE] = replace(message, 'page-2#', '') WHERE [ICODE]message[/ICODE] LIKE '%https://www.oursitedomain.com%'
I can confirm that this query does not remove the page-2 part only for links with our site domain; it does remove all occurances of page-2# within all posts that somewhere contain https://www.oursitedomain.com leaving only garbage behind.

@ everyone: Do not run this query!
 
Top Bottom