How to Fix Document ID Links & Copy Links After Migration
Published:
Last updated: 2026-11-29
When SharePoint sites are migrated to a new tenant or restructured within the same tenant, Document ID links and Copy Link (durable link) URLs often break. These links point at a document by an identifier (a Document ID or the item's GUID) instead of its file path. After a migration the identifiers on the destination are usually different, so the old links no longer resolve.
Overview
When SharePoint sites are migrated to a new tenant or restructured within the same tenant, Document ID links and Copy Link (durable link) URLs often break. These links point at a document by an identifier (a Document ID or the item's GUID) instead of its file path. After a migration the identifiers on the destination are usually different, so the old links no longer resolve.
There are two ways to fix them:
| Method | When to use it | |
|---|---|---|
| A (recommended) | Prepare site for link correction: record every link form on the source before the move, then build the Find & Replace mapping automatically on the destination after the move. | You can run the Toolkit on the source before the content is moved. Works with any migration tool, including SPE Copy. |
| B | Item Inventory + manual rules: export Document IDs and Item GUIDs with the Item Inventory report and build wildcard rules in Excel. | The move has already happened and the source wasn't prepared, or you only need to fix a handful of documents. |
Tip: Whichever method you use, always run Link Find & Replace with Flag Only turned on first. The report shows every replacement it would make without changing anything.
Understanding the Problem
Document ID Links
SharePoint Document IDs give each document a persistent identifier. Links that use Document IDs look like this:
https://old-tenant.sharepoint.com/sites/hr/_layouts/15/DocIdRedir.aspx?ID=HRDOC-1234-5678
https://old-tenant.sharepoint.com/sites/finance/_layouts/15/DocIdRedir.aspx?ID=FINDOC-2024-0042
The Document ID format is configurable per site collection. Common patterns include HRDOC-####-####, PROJX-######, or default alphanumeric IDs like MSDOC-XXXXXXXX.
Document IDs are assigned by the tenant. When content moves, the destination normally assigns new IDs (unless the migration tool carries the old values across), and the old DocIdRedir.aspx page either no longer exists or can't resolve the old ID.
Copy Link (Durable Link) and GUID-based URLs
When users click Copy Link or open a file in Office, the URL often contains the item's unique GUID:
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/Doc.aspx?sourcedoc={3f2504e0-4f89-11d3-9a0c-0305e82c3301}&action=edit
https://old-tenant.sharepoint.com/sites/projects/Shared Documents/doc1.docx?d=w3f2504e04f8911d39a0c0305e82c3301
https://old-tenant.sharepoint.com/:w:/s/projects/EWBFLz-JT9MamgwDBegsMwEBkl2oJ5FMsE?e=abc123
These links use the sourcedoc GUID, the ?d=w… short form, or an encoded token (sharing links such as /:w:/s/…). Migrated items get a new GUID, and sharing links are bound to the source tenant, so none of them survive the move. A path-based rule can't fix them because nothing in the link names the file.
Method A (Recommended): Prepare Site for Link Correction
Prepare site for link correction is a single task with three steps. You choose the step on the task's Settings tab under Which step is this run.
| Step | Run on | When | What it does | Writes to SharePoint? |
|---|---|---|---|---|
| 1. Run on source | Source site(s) | Before the move | Records every link form of every file, folder, item, page and list (including Document ID and GUID links) and stamps them on each item in two columns. | Adds two columns and fills them in. Modified dates are preserved. |
| 2. Run on target (build mapping) | Destination site(s) | After the move | Reads the stamped columns back, pairs each moved item with its old links, and builds the Find & Replace mapping. | No |
| 3. Remove the stamped columns | Source, destination, or both | After the links are fixed | Deletes the two stamped columns from every list that has them. | Removes the columns. Items aren't edited. |
Modified dates are not affected. None of the steps changes an item's Modified, Modified By or version history. Stamping is a system update (no new version is created), and deleting a list column is a schema change that SharePoint doesn't record against the items.
The Two Stamped Columns
Step 1 adds these columns to every list and library it walks, in the column group SharePoint Essentials Toolkit Migration Columns:
| Column (display name) | Internal name | Type | Contents |
|---|---|---|---|
| SPE Source URLs | SPESourceUrls |
Multiple lines of text | Every URL the item could be opened by on the source, one per line. |
| SPE Source Key | SPESourceKey |
Single line of text (indexed) | siteUrl|listId|uniqueId|listUrl of the source item: a stable key that doesn't depend on paths. |
Because the values are stored on the items, they travel with the content to the destination. Step 2 can then pair every moved item with where it came from, whichever tool moved it and however the paths changed along the way.
For a document in a library with the Document ID service enabled, SPE Source URLs contains entries like these:
https://old-tenant.sharepoint.com/sites/projects/Shared Documents/proj-123/doc1.docx
/sites/projects/Shared Documents/proj-123/doc1.docx
https://old-tenant.sharepoint.com/sites/projects/Shared Documents/Forms/AllItems.aspx?id=%2Fsites%2Fprojects%2FShared%20Documents%2Fproj-123%2Fdoc1.docx
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/DocIdRedir.aspx?ID=PROJX-1234-5678
/sites/projects/_layouts/15/DocIdRedir.aspx?ID=PROJX-1234-5678
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/Doc.aspx?sourcedoc={3F2504E0-4F89-11D3-9A0C-0305E82C3301}
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/Doc.aspx?sourcedoc=%7B3F2504E0-4F89-11D3-9A0C-0305E82C3301%7D
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/WopiFrame.aspx?sourcedoc={3F2504E0-4F89-11D3-9A0C-0305E82C3301}
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/guestaccess.aspx?docid=3f2504e04f8911d39a0c0305e82c3301
https://old-tenant.sharepoint.com/sites/projects/_layouts/15/download.aspx?UniqueId=3f2504e0-4f89-11d3-9a0c-0305e82c3301
?d=w3f2504e04f8911d39a0c0305e82c3301
List items also get their DispForm.aspx?ID=, EditForm.aspx?ID= and listform.aspx forms, and folders get their library view (?RootFolder= / ?id=) forms. You don't need separate entries for percent-encoded paths (Shared%20Documents): Link Find & Replace decodes paths before matching, so one decoded rule covers both spellings.
Important: Your migration tool must carry custom column values across for Step 2 to read the stamp. If it doesn't, but you moved the content with an SPE Copy Lists / Copy Sites task, Step 2 can use that task's history instead (see Mapping source below).
Step 1: Run on the Source (Before the Move)
- Create a new Prepare site for link correction task and select the source site(s) on the Sites tab.
- On the Settings tab, choose 1. Run on source.
- Under What to record on the source, review the options:
| Option | Default | Notes |
|---|---|---|
| Stamp the links found on each item | On | Adds the SPE Source URLs and SPE Source Key columns and writes them on every item. Turn it off only if you'll use SPE Copy job history as the mapping source. In that case Step 1 just reports and exports. |
| Record Document IDs | On | Where the Document ID service is active, records each item's Document ID and its DocIdRedir.aspx link so Document ID links can be corrected too. Leave this on if your content uses Document ID links. |
| Include folders | On | |
| Include pages | On | Site pages and wiki pages. Page libraries must also be included on Lists & content > Inclusions. |
| Record sharing links and recipients | Off | For every item with its own permissions, records each sharing link, its type and permission level, who created it, and everyone it reaches (with e-mail addresses). This feeds the Broken Sharing Links report after the move. It costs one extra request per item with unique permissions. |
| Also list people with direct access | Off | Adds people with a direct grant on the item to the notification list. |
- Run the task. The report lists every catalogued object with its stamp status (Stamped, Already stamped, Skipped: checked out, and so on), and the workbook's Source URLs sheet lists every recorded link form.
Note: Checked-out files are skipped and reported as Skipped: checked out. Check them in and run Step 1 again before you migrate. Items that are already stamped are left as they are.
Move the Content
Migrate or copy the content with SPE Copy or any other tool. The stamped columns move with the items.
Step 2: Run on the Target (After the Move)
- Open the same task (or create a new one), select the destination site(s) on the Sites tab, and choose 2. Run on target (build mapping).
- Under Where the old-to-new pairs come from, choose the Mapping source:
| Mapping source | Use when |
|---|---|
| Stamped 'SPE Source URLs' column (any migration tool) | The columns were carried across. This is the default. |
| SPE Copy job history | The content was moved with an SPE Copy Lists / Copy Sites task. Pick the task under Copy task that moved the content. No stamping is needed. |
| Both (column first, then Copy job history) | Most items have the stamp and the Copy task fills in any that lost it. |
- Under How the new links are written, decide what each NEW LINK should be:
| Option | Default | Effect |
|---|---|---|
| Use Document ID for new link | Off | Off: NEW LINK is the item's physical address on the destination. On: NEW LINK is the destination item's own Document ID link (DocIdRedir.aspx?ID=…), which keeps working if the file is renamed or moved again. Requires the Document ID Service site collection feature on the destination, with IDs already assigned. |
| Fall back to the physical link when there is no Document ID | On | With Document ID mode on, items without a Document ID yet (such as folders, or libraries without the service) get their physical address instead of being reported as Document ID not assigned yet. |
| Lead with site, list and folder prefix rules | On | One rule per list or library (and per site whose lists all moved together) rewrites every file path below it. Items that landed elsewhere, or were renamed, get exact rules of their own. This keeps the mapping small. Turn it off if items were scattered during the move. Prefix rules aren't used in Document ID mode. |
- Moving to another server or tenant? Add one rule under Additional rules, for example
https://old-tenant.sharepoint.com→https://new-tenant.sharepoint.com. Generated path rules are server-relative (/sites/hr/Shared Documents/...), so they match absolute and relative links alike but leave the host of an absolute link unchanged. Additional rules run after the mapping and fix the host. - Run the task.
What Step 2 Generates for Document ID and Copy Links
You don't write any wildcard rules. For every moved item, Step 2 produces:
- Path rules (Contains, replace only the matched part) for the item's physical, server-relative and library view links. These are usually covered by a single list or site prefix rule.
- Whole-link rules (Contains, replace completely) for every identifier-based form recorded in Step 1:
DocIdRedir.aspx?ID=,Doc.aspx/WopiFrame.aspx?sourcedoc=,guestaccess.aspx?docid=,download.aspx?UniqueId=,?d=w…,DispForm.aspx?ID=and recorded sharing links. Each one replaces the entire old link with the item's new link.
Example output for the document above, moved from /sites/projects on the old tenant to /sites/projects-archive on the new tenant:
| Old Value | New Value | Method |
|---|---|---|
/sites/projects/_layouts/15/DocIdRedir.aspx?ID=PROJX-1234-5678 |
https://new-tenant.sharepoint.com/sites/projects-archive/Shared Documents/proj-123/doc1.docx |
Replace completely |
/sites/projects/_layouts/15/Doc.aspx?sourcedoc={3F2504E0-4F89-11D3-9A0C-0305E82C3301} |
https://new-tenant.sharepoint.com/sites/projects-archive/Shared Documents/proj-123/doc1.docx |
Replace completely |
?d=w3f2504e04f8911d39a0c0305e82c3301 |
https://new-tenant.sharepoint.com/sites/projects-archive/Shared Documents/proj-123/doc1.docx |
Replace completely |
/sites/projects/Shared Documents |
/sites/projects-archive/Shared Documents |
Replace only matching string (prefix) |
https://old-tenant.sharepoint.com |
https://new-tenant.sharepoint.com |
Replace only matching string (additional rule) |
With Use Document ID for new link on, the New Value of each rule becomes the destination's Document ID link instead, for example https://new-tenant.sharepoint.com/sites/projects-archive/_layouts/15/DocIdRedir.aspx?ID=NEWDOC-17-42.
The rules are ordered so the engine always meets the most specific rule first. Whole-link (Document ID, GUID, form and sharing link) rules come before prefix rules, so a site prefix never half-rewrites a Doc.aspx?sourcedoc= link into one that points at a GUID the destination doesn't have. Within each group, deeper and longer paths come first.
Step 2 Output
- Report: every paired item with its status (Mapped, Unresolved, Document ID not assigned yet), how it was matched (SPESourceKey, Copy job history, Prefix, Item) and the number of rules it produced.
- Workbook (saved under the Reports folder in a Link Preparation sub-folder named after the task, unless you set Folder under Export):
- Mapping: every rule, ready for Link Find & Replace.
- Unresolved: source items with no match on the destination.
- Broken Sharing Links: if sharing links were recorded in Step 1, each broken sharing link with its creator, recipients and e-mail addresses, and the item's new location, so you know who to notify.
- A CSV of the mapping that you can import into Link Find & Replace by hand.
Fix the Links
- After Step 2 completes, click Fix links now in the task settings (under This run already built a mapping).
- Link Find & Replace opens with the generated mapping and any additional rules loaded, and with the destination sites selected. The first run is a dry run (Flag Only).
- Review the report, then turn off Flag Only and run it again to apply the changes.
Step 3: Remove the Stamped Columns
Once the links are fixed and you no longer need the mapping, run the task with 3. Remove the stamped columns on the source, the destination, or both. Both SPE Source URLs and SPE Source Key are deleted from every selected list that has them, along with their values. Lists that never had them are left alone. Removing a column requires Manage Lists permission on each list.
Tip: Keep the columns until you've run Link Find & Replace on every site that might link to the moved content, including sites that weren't migrated. Step 2 can be re-run at any time as long as the stamp is still on the items.
Method B: Item Inventory and Manual Rules
Use this method when the source wasn't prepared before the move. You build the old-identifier to new-path mapping yourself from the Item Inventory report.
Step 1: Run an Item Inventory Report
Which environment to run it on
- Document IDs were migrated with the content (the destination has the same Document ID values): run the Item Inventory on the destination. The report gives you each Document ID and its new physical path directly.
- Copy Links (Item GUIDs), or Document IDs that were not migrated: run the Item Inventory on the source. Only the source knows which file each old Document ID or GUID belonged to. You then work out where each file landed on the destination.
Configure the report
- Create a new Item Inventory job and select the site(s) that contain the documents (see above for source or destination).
- In the Job Options, locate the Additional Fields section.
- Add the field(s) you need:
| Broken Link Type | Additional Field to Add |
|---|---|
Document ID links (DocIdRedir.aspx?ID=...) |
Document Id |
Copy Links with GUIDs (sourcedoc={...}) |
(Item GUID is included by default) |
- Run the report.
What the report gives you
| Item URL (Physical Path) | Document Id | Item GUID |
|---|---|---|
https://tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
PROJX-1234-5678 |
3f2504e0-4f89-11d3-9a0c-0305e82c3301 |
https://tenant.sharepoint.com/sites/projects/proj-123/report.pdf |
PROJX-9012-3456 |
7a1b2c3d-4e5f-6789-abcd-ef0123456789 |
https://tenant.sharepoint.com/sites/hr/policies/handbook.docx |
HRDOC-2024-0001 |
a1b2c3d4-e5f6-7890-abcd-ef1234567890 |
If the report came from the source, convert each Item URL into its new path. For example, if https://tenant.sharepoint.com/sites/projects/ was migrated to https://new-tenant.sharepoint.com/sites/projects/, then .../sites/projects/proj-123/doc1.docx becomes https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx.
You now have the mapping:
- Document ID → New physical path
- Item GUID → New physical path
Step 2: Create Find & Replace Rules
Each broken link needs a rule that matches the old identifier and replaces the entire URL with the new physical path.
Fixing Document ID links
| Field | Value |
|---|---|
| Old Value | *PROJX-1234-5678* |
| New Value | https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
| Match Type | Wildcard |
| Replacement Behavior | Partial Match or Completely Replace. The * already covers the entire match, so either works. |
Why this works: The wildcard *PROJX-1234-5678* matches any URL that contains the Document ID, regardless of the tenant, site path or DocIdRedir.aspx structure around it. The entire matched URL is replaced with the direct file path.
| Old Value | New Value | Match Type |
|---|---|---|
*PROJX-1234-5678* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
Wildcard |
*PROJX-9012-3456* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/report.pdf |
Wildcard |
*HRDOC-2024-0001* |
https://new-tenant.sharepoint.com/sites/hr/policies/handbook.docx |
Wildcard |
Fixing Copy Link / durable link URLs
| Field | Value |
|---|---|
| Old Value | *3f2504e0-4f89-11d3-9a0c-0305e82c3301* |
| New Value | https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
| Match Type | Wildcard |
| Replacement Behavior | Partial Match or Completely Replace. The * already covers the entire match, so either works. |
Why this works: Doc.aspx?sourcedoc= links contain the item GUID, so the wildcard *{guid}* matches the full URL regardless of the surrounding structure. Sharing links (/:w:/s/…) don't contain the GUID, so this method can't fix them. Use Method A with Record sharing links and recipients turned on to catch those.
| Old Value | New Value | Match Type |
|---|---|---|
*3f2504e0-4f89-11d3-9a0c-0305e82c3301* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
Wildcard |
*7a1b2c3d-4e5f-6789-abcd-ef0123456789* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/report.pdf |
Wildcard |
*a1b2c3d4-e5f6-7890-abcd-ef1234567890* |
https://new-tenant.sharepoint.com/sites/hr/policies/handbook.docx |
Wildcard |
Step 3: Import Rules from Excel
For more than a handful of documents, build the rules in Excel and import them (see How to Import Link Find & Replace Rules from Excel).
| Column A (Old Value) | Column B (New Value) | Column C (Match Type) |
|---|---|---|
*PROJX-1234-5678* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
Wildcard |
*PROJX-9012-3456* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/report.pdf |
Wildcard |
*3f2504e0-4f89-11d3-9a0c-0305e82c3301* |
https://new-tenant.sharepoint.com/sites/projects/proj-123/doc1.docx |
Wildcard |
- Export or copy the Item Inventory report to Excel.
- In Column A, wrap each Document ID or GUID with
*on both sides, for example*PROJX-1234-5678*. - In Column B, paste the new physical path.
- In Column C, enter
Wildcardfor all rows. - Import the file into your Link Find & Replace job.
Step 4: Run the Link Job
- Target the destination sites: run Link Find & Replace against the sites in the new environment whose content contains the broken links.
- Enable Flag Only on the first run to preview every match without making changes.
- Review the report and check that the right links are matched and the replacement values are correct.
- Run with changes enabled: turn off Flag Only and run again to apply the replacements.
Advanced: Using Regex for Pattern-Based Replacement
If your Document IDs follow a predictable pattern and the site structure is preserved, a Regular Expression rule can handle many links at once. See How to Use Wildcard & Regex in Link Find & Replace.
Redirect all Document ID links from one site
| Field | Value |
|---|---|
| Old Value | *old-tenant.sharepoint.com/sites/hr/_layouts/15/DocIdRedir.aspx* |
| New Value | https://new-tenant.sharepoint.com/sites/hr/Documents |
| Match Type | Wildcard |
| Replacement Behavior | Partial Match or Completely Replace |
Preserve the Document ID in the new URL
Only use this when the destination has the same Document ID values (the IDs were migrated with the content), on a different tenant or site:
| Field | Value |
|---|---|
| Old Value | https://old-tenant\.sharepoint\.com/sites/\w+/_layouts/15/DocIdRedir\.aspx\?ID=(.+) |
| New Value | https://new-tenant.sharepoint.com/sites/hr/_layouts/15/DocIdRedir.aspx?ID=$1 |
| Match Type | Regular Expression |
| Replacement Behavior | Partial Match. Completely Replace will not work. |
Tips & Best Practices
- Prepare the source before you migrate. Running Method A's Step 1 before the move takes a few minutes and removes all the manual mapping work. Once the source is gone, you're limited to Method B.
- Always use Flag Only first. Check that the rules match the intended links and nothing else. Fix links now starts with Flag Only on.
- Check that your migration tool copies custom columns. If the SPE Source URLs / SPE Source Key values don't arrive on the destination, Step 2 reports the items as Unresolved. If you used SPE Copy, choose SPE Copy job history or Both as the mapping source.
- Add a server URL rule for cross-tenant moves. Generated path rules are server-relative, so add
https://old-tenant.sharepoint.com→https://new-tenant.sharepoint.comunder Additional rules. - Document ID mode needs IDs on the destination. Before you use Use Document ID for new link, activate the Document ID Service feature on the destination site collection and wait for IDs to be assigned. Otherwise every item falls back to its physical link, or is reported as Document ID not assigned yet.
- Run Link Find & Replace everywhere the content is linked from. Links to moved documents often live on other sites, in Teams tabs and in documents outside the migrated scope. Run Link Find & Replace (with the generated mapping) against those sites too.
- Tell people about broken sharing links. Sharing links can't be redirected outside SharePoint content (for example, links in e-mails). Use the Broken Sharing Links sheet to notify each recipient of the new location.
- GUIDs are case-insensitive. Wildcard matching ignores case, so
*3F2504E0*and*3f2504e0*both match. - Handle URL-encoded GUIDs (Method B). Some Copy Link URLs encode the braces or dashes of the GUID (
%7B,%2D). Method A records both the braced and encodedsourcedocforms automatically. With Method B, add a second rule for the encoded form if needed. - Clean up when you're done. Run Step 3 to remove the stamped columns once every link has been fixed.