How to solve broken links after migrating to another server
Asked by Stefan Wolff:

I migrated Confluence (V. 6.4.3) to another server yesterday. Now I found a bug with the links within the page and a workaround which is not suitable for each site.

After migrating to the new server on the first view everything looked fine. But as soon as I started to edit an already existing page all the links on this page link to the page itself after releasing the page. (Even if I don't make any changes and just save the content after pressing the edit button the links on the page and all the links to the data which is attached to this page are broken.)

I figured out that I can fix this behaviour by doing the following steps:

1. Edit the page (don't do any change but just save the page to produce a new version)

2. Go to the version history and reproduce the prior version (before migration) Now the links somehow get repaired and it is possible to edit the page again without damaging the links.

But there must be an other option to fix this issue. I can't open every single page created within Confluence to save it and restore the prior version of it. This will take months. Please tell me how to fix this bug on the whole confluence instance.

The funny thing is that links that contain special characters like "\&" or non-english special characters like "?" work fine and are not affected by this issue.

Thank you very much in advance


Answers:
author: barnesy
body: Hi [@Stefan Wolff](/t5/user/viewprofilepage/user-id/218736), the Bug report is the best place to share your comments and vote as well as watch for a workaround. This helps all information be captured in one place. This issue is high on our priority list and I anticipate that it will be resolved in the near future.


author: Alexey Astafyev
body: Recently we faced with a similar problem. Is there solutions?

<https://community.atlassian.com/t5/Confluence-questions/Broken-links-after-migration-Confluence/qaq-p/1815192#M219431>


author: Andreas Wachter
body: Hi,

we have also this issue...  
We just changed the URL. The server was not migrated.

Is this issue already on a roadmap? Will it be fixed? Is there a workaround?

We also upgraded to the newest Confluence version but the issue still persists.

BR

comments: author: Andreas Wachter
body: Sorry, have not followed the ticket link. My bad.

This issue still persists in Confluence 6.7.2.


author: Andreas Wachter
body: Hi again,

after upgrading we had to ++deactivate and reactivate++ ++Colaborative editing++ and ++restart indexing++.

Now the old pages can be edited without loosing links.

BR


author: Chii
body: [@Andreas Wachter](/t5/user/viewprofilepage/user-id/216655), what is the issue in 6.7.2 that you see?

After upgrading to 6.7.2, and then changed the base url, editing a draft that has unpublished content from pre-baseurl-change should no longer break that link. Existing drafts or pages that has had the issue from a prior version will remain as is though (as the information about the link has already been lost).

As for turning off collaborative editing, that will have the side effect of dropping unpublished draft content (may be undesirable), and if the draft has already been autosaved, this will not fix the issue. Re-indexing should not be required (as indexing is a separate subsystem to collaborative editing).


author: Andreas Wachter
body: [@Chii](/t5/user/viewprofilepage/user-id/502195), I'm sorry if my previous post was not clear. There is no issue any more.

First we had Confluence 6.5.1, then we changed the URL which caused the problem as described and upgraded to 6.7.2.

After this upgrade to 6.7.2 the issue was still here. All pages that was created before URL change in Version 6.5.1 lost their old links after saving.

After searching a bit longer for this issue I found this procedure with de-/reactivating Colaborative editing and restart indexing. After doing this, new pageupdates on old pages didn't destroyed old links anymore.

The already destroyed links can be recovered manually by comparing the current pageversion with previous pages versions.

We also created a database query to find all affected pages. This query shows also some not affected pages, but it makes life easier by finding pages out of hundreds.

```
SELECT s.SPACENAME,c.TITLE, ROUND (? ?
??????? (
??????????? LENGTH(b.BODY)
??????????? - LENGTH( REPLACE ( b.BODY, "<ac:link />", "") ) 
??????? ) / LENGTH("<ac:link />")?????? ?
??? ) AS count FROM confluencedb.SPACES s INNER JOIN confluencedb.CONTENT c on s.SPACEID=c.SPACEID JOIN confluencedb.BODYCONTENT b ON c.CONTENTID=b.CONTENTID WHERE PREVVER is NULL AND b.BODY like '%<ac:link />%'
??? ORDER BY s.SPACENAME;
```


author: Andreas Wachter
body: [@Chii](/t5/user/viewprofilepage/user-id/502195), I'm sorry if my previous post was not clear. There is no issue any more  

First we had Confluence 6.5.1, then we changed the URL which caused the problem as described and upgraded to 6.7.2.  

After this upgrade to 6.7.2 the issue was still here. All pages that was created before URL change in Version 6.5.1 lost their old links after saving.  

After searching a bit longer for this issue I found this procedure with de-/reactivating Colaborative editing and restart indexing. After doing this, new pageupdates on old pages didn't destroyed old links anymore.  

The already destroyed links can be recovered manually by comparing the current pageversion with previous pages versions.

<br />

<br />

We also created a database query to find all affected pages. This query shows also some not affected pages, but it makes life easier by finding pages out of hundreds.

```
SELECT s.SPACENAME,c.TITLE, ROUND (? ?
??????? (
??????????? LENGTH(b.BODY)
??????????? - LENGTH( REPLACE ( b.BODY, "<ac:link />", "") ) 
??????? ) / LENGTH("<ac:link />")?????? ?
??? ) AS count FROM confluencedb.SPACES s INNER JOIN confluencedb.CONTENT c on s.SPACEID=c.SPACEID JOIN confluencedb.BODYCONTENT b ON c.CONTENTID=b.CONTENTID WHERE PREVVER is NULL AND b.BODY like '%<ac:link />%'
??? ORDER BY s.SPACENAME;
```


author: Robert Skawinski
body: Exactly the same issue happens in Confluence 6.11

Deactivating collaborative editing, reindexing and reactivating collaborative editing solves the problem.


author: Stefan Wolff
body: "What steps were taken to move the Confluence instance to the new server."

1. Backup of the complete "Application Data" Folder with subfolders. SQL-Backup of the Database. Shutdown of Services and Database

2. Install Confluence on new Server. Restore Application Data and SQL-DB-Restore

3. Start Confluence

"Was the base URL changed? "

Yes.

"If you create a new page with links and edit it, do the links break in the same way?"

No, it just happens to links that were existing before the migration already. And it only happens to internal links (other pages within Confluence and attached files). External links (e.g. atlassian.com or google.com still work fine and are not broken) And like I told you in my post from last week - I found a way to repair those broken links by using the version history.

Would there be a possibility to alter data in the SQL-DB to get the links fixed again in one rush?

I also checked how Confluence creates the links in HTML:

Working link before it's broken:

\<p class="auto-cursor-target"\>\&rarr; \<ac:link\>\<ri:page ri:content-title="Name_of_the_Page" /\>\</ac:link\>\</p\>

After migration the link looks like this:  
\<p class="auto-cursor-target"\>\&rarr; \<ac:link /\>\</p\>


author: AnnWorley
body: Please let me know:

* What steps were taken to move the Confluence instance to the new server.
* Was the base URL changed?
* If you create a new page with links and edit it, do the links break in the same way?

Please edit a page, save it so the links are broken, then paste the storage format into a code block on this thread. The storage format can be copied from the page tools menu\>View Storage format. This will allow me to examine the links more closely rather than asking you to describe what you see.

comments: author: AnnWorley
body: I take it back - we don't have to gather so much information because it is a known issue: [Links are changed to a self referential link of the page once you edit the page](https://jira.atlassian.com/browse/CONFSERVER-51998)

I hope you will vote and comment to emphasize the inconvenience of this. That will automatically add you as a watcher so you can get updates on progress.


author: Stefan Wolff
body: Thanks for the information. This shows at least Atlassian did't fix this bug since months. It doesn't really help me to get rid of the problem and I would rather read an answer like "we just fixed it - install the bugfix".

So please tell your coders to fix this issues asap. Thanks a lot in advance.