When you share a file in SharePoint with an external user, the link sometimes opens a different file or the wrong version. This problem usually happens because of how SharePoint resolves sharing links when files are moved, renamed, or when multiple files share the same name. This article explains the technical cause of this issue and gives you specific steps to fix it and prevent it from happening again.
Key Takeaways: External Sharing Links and File Resolution
- SharePoint library > Copy link > Anyone with the link: Creates a link that resolves to the file at the moment it is opened, not when the link was created.
- SharePoint admin center > Sharing > File and folder links: Default link type (Anyone, People in your organization, or Specific people) affects how link resolution works.
- File move or rename within the same library: Breaks the link binding because the link stores an internal ID that points to a specific file location.
Why SharePoint Sharing Links Open the Wrong File
SharePoint sharing links are not permanent file references. When you create a sharing link for a file, SharePoint stores a unique identifier called a content hash or a document ID. When an external user clicks the link, SharePoint looks up that identifier to find the file. If the file has been moved to a different folder within the same library, renamed, or replaced with a different file that has the same name, SharePoint may resolve the link to a different file or show an error.
The root cause is that SharePoint does not lock the file to the original link. Instead, it searches the library for a file that matches the stored identifier. If two files share the same name in the same library, the link can redirect to the wrong file. This behavior is by design. It prevents broken links when files are moved within the same library, but it also introduces ambiguity.
How Link Resolution Works
When you generate a sharing link, SharePoint creates a URL that contains a unique token. The token is associated with the file’s internal ID and the library’s ID. When the link is opened, SharePoint checks the token, then looks up the file in the library by its current location. If the file is no longer at that location, SharePoint falls back to searching by file name. If multiple files match the name, SharePoint may return the wrong file.
Common Scenarios That Cause Wrong File Resolution
Three scenarios most often trigger this problem:
- File moved to a different folder within the same library: The internal ID changes, and SharePoint uses the file name to locate the file. If another file with the same name exists, it opens that one.
- File renamed after sharing: The original name is lost. SharePoint may look for a file with a similar name or return a 404 error.
- File replaced with a new version with the same name: If the new file is a different document, the link may still open the original file because the internal ID is tied to the original upload.
Steps to Fix an External Sharing Link That Opens the Wrong File
Use these steps to diagnose and fix the link issue. Start with the simplest fix and move to more advanced steps if needed.
- Check the file name for duplicates
Open the SharePoint library that contains the shared file. Look for any other file in the same library that has the exact same name, including the file extension. If duplicates exist, rename one of them. Right-click the duplicate file, select Rename, and add a version number or date. Then test the external link again. - Verify the file location
Ask the person who created the link to open it themselves. If it opens the correct file for them, compare the file location with the location the external user sees. If the file was moved, move it back to the original folder. Right-click the file, select Details, and check the Path property. If the path does not match the original location, move the file back. - Regenerate the sharing link
Delete the existing link and create a new one. In the SharePoint library, select the file, click the three dots (More actions), then select Manage access. Find the external link in the list and click the Delete icon. Then click Copy link, choose the appropriate permissions (Anyone with the link or Specific people), and click Apply. Copy the new link and send it to the external user. - Use the Get sharing link API to inspect the link target
If you have SharePoint admin access, use the SharePoint REST API to check which file the link resolves to. Open PowerShell or a browser with the SharePoint admin URL. Run the following GET request:GET https://[tenant]-admin.sharepoint.com/_api/web/GetSharingLinkByToken('linktoken'). Replacelinktokenwith the token from the sharing URL. The response shows the file’s unique ID and current URL. If the ID does not match the intended file, the link is pointing to a different file. - Enable Document ID service for permanent links
If you frequently share files that get moved or renamed, enable the Document ID service in SharePoint. This service assigns a permanent ID to every document. Sharing links that use Document ID always resolve to the correct file, even after moves or renames. Go to SharePoint admin center > Settings > Document ID service. Click Turn on Document ID service, then click OK. It may take up to 24 hours for existing files to get a Document ID.
If the External Sharing Link Still Opens the Wrong File
If the main fix steps do not resolve the problem, check these related issues.
External user opens a file from a different library
This happens when two libraries in the same site have files with the same name. The link token is scoped to the site, not the library. SharePoint searches all libraries in the site when resolving the link. To fix this, move the file to a unique location or rename it so no other file in the site shares the name.
Link opens an older version of the file
If the file has version history enabled, the link may open a previous version. This occurs when the file was replaced with a new version that has a different internal ID. Open the file in SharePoint, click the version history icon (clock icon), and check the latest version. If the latest version is not the current one, restore it. Then regenerate the sharing link.
Link shows a 404 error or access denied
A 404 error means SharePoint cannot find any file matching the link token. This usually happens when the file was deleted or moved to a different site. Restore the file from the SharePoint recycle bin in the site where the file was originally shared. If the file was moved to a different site, create a new sharing link from the new location.
| Item | Sharing Link (default) | Document ID Link |
|---|---|---|
| Link resolution | Resolves by file location and name at open time | Resolves by permanent Document ID, independent of location |
| Works after file move within same library | Yes, but may open wrong file if duplicate name exists | Yes, always opens the correct file |
| Works after file rename | No, may show error or wrong file | Yes, because Document ID does not change |
| Works after file moved to different site | No, link breaks | No, link breaks |
| Requires admin setup | No, default feature | Yes, must be enabled in SharePoint admin center |
Now you can identify why an external sharing link opens the wrong file and apply the correct fix. Start by checking for duplicate file names in the same library. If that does not work, regenerate the link. For ongoing prevention, enable the Document ID service in the SharePoint admin center. This ensures that sharing links always resolve to the correct file even when the file is moved or renamed.