iOS apple-app-site-association - does it need to be off the root of my server?

I am trying to configure deep linking for my Capacitor App and am following the instructions here: https://capacitorjs.com/docs/guides/deep-links. Apple mentions that

“The file needs to be accessible via HTTPS—without any redirects—at https:///apple-app-site-association or https:///.well-known/apple-app-site-association. Next, you need to handle universal links in your app”

and

“Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory.”

https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html

My questions is: does the .well-known directory absolutely need to be off the root of my server? We use Google Cloud and Kubernetes and the website I need to link wit does not live at domain.com, it lives at domain.com/myapp. I need to be able to serve the apple-site-association file at domain.com/myapp/.well-known/apple-app-site-association. However, when I use serve the association file at domain.com/myapp/.well-known/apple-app-site-association I get “Error cannot fetch app site association” from https://search.developer.apple.com/appsearch-validation-tool. I’ve tested deep linking with my app on a device (just to see if the validator was wrong) but am always routed to our website and not our application. Any help/advice would be greatly appreciated.

Might it be possible to have DNS for myapp.domain.com point to the same webserver? I would think the virtual hosting capability of whatever webserver you’re using should be able to handle this.

Hey there,
Yes - as far as I know the .well-known directory does need to be located at the domain root.
What you can do is setup a subdomain to use myapp.domain.com and point it to domain.com/myapp. This way it should work correctly.