How to handle deep linking in your mobile app on AEM dispatcher
Goal
It happens sometimes to use AEM to deliver content both to the website and the mobile application, and your mobile application uses deep links. In order to have everything working, there are a few steps to follow.
Procedure
Access in ssh to your Dispatcher server(s) and go under you DocumentRoot folder, which generally is located at “/var/www/html“. Here you can create a specific folder to manage these new files. Once done, create or upload apple-app-site-association and assetlinks.json files.
Then go in your vhost file, which should be located in the folder conf.d/available_vhost if you are using the latest folders structure. Inside the rewrite module (“<IfModule mod_rewrite.c>”) add your rewrite rules, for example:
#deeplink ios
RewriteRule ^/.well-known/apple-app-site-association /your-folder-path/apple-app-site-association [PT,L]
#deeplink android
RewriteRule ^/.well-known/assetlinks.json /your-folder-path/assetlinks.json [PT,L]
Last thing to do, again in the vhost file, is to set the following rule for the apple-app-site-application file.
<FilesMatch "apple-app-site-association">
ForceType application/json
</FilesMatch>
That’s all. Remember the files must be served over https:// with a valid SSL certificate.
Cheers! 🍻