Widely used integrations with Apple and Android Operating System's deep links, such as Payment Processors, require verification of ownership of a site through the construction of specific folders and content on the integrating page. These will typically start from the folder path /.well-known/ and contain individual files with JSON with configuration data. Common files referenced for this are assetlinks.json or apple-site-association.
With Salesforce, it is not possible to directly set the /.well-known path for any site. Salesforce additionally pre-populates it's own configurations at some of these endpoints. However, with the use of URL Rewriters, we can present a page to the service that appears to be at the appropriate path, but it instead serves a Visualforce page with the needed content.
This method does generate a redirect, so it will not work with services that do not follow redirects, or require a 200 OK Status Code be returned.
First, create a Visualforce page with your required information, and give it a descriptive, unique name to allow the URL rewriter to identify it easily. Be sure to specify the contentType appropriately. Ours here is called "myAssetLink":
<apex:page standardStylesheets="false" sidebar="false" showHeader="false" applyHtmlTag="false" applyBodyTag="false" contentType="text/json"> <!-- Specify your JSON content here --> </apex:page>
Ensure the checkbox for "Available for Lightning Experience, Experience Builder Sites and the mobile app" is enabled if your use case is for Mobile Publisher, Experience Cloud or similar Lightning solutions.
Each file will need it's own Visualforce page, so create as many as needed. Depending on the specifics of your integration you may need multiple copies of files for different sites in your org.
Next, create your URL Rewriter. If you are integrating your third-party across multiple sites then multiple URL Rewriters may be needed. Below is an example implementation for setting Android Assetlinks, continuing the above example:
global with sharing class AssetLinkRedirect implements Site.UrlRewriter{
//Variables to represent the user-friendly URLs for the new page
String ASSETLINK_PAGE = '/apex/myAssetLink';
global PageReference mapRequestUrl(PageReference myFriendlyUrl){
String url = myFriendlyUrl.getUrl();
system.debug('=====URL======'+url);
if(url != null && url.endsWith('assetlinks.json')){
system.debug('=====Modified Android Asset Links======');
return new PageReference(ASSETLINK_PAGE);
}
return null;
}
global List<PageReference> generateUrlFor(List<PageReference> mySalesforceUrls){
return null;
}
}
In this Apex Class, we implement the Site.UrlRewriter interface, and use the mapRequestUrl method to check if the URL being passed matches our desired signature. Then we return a new PageReference to the custom Visualforce page create earlier that hosts the JSON content.
Once the Apex Class is created, navigate to your desired site to set it as the URL rewriter.
For Salesforce Sites:
For Experience Cloud sites:
Finally, test your implementation by navigating to your configured page directly in your browser.
000396664

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.