Praxiteles
Praxiteles

Reputation: 6030

How to web serve a file without an extension on GoDaddy's web hosting service?

When setting up universal links for iOS apps, Apple states:

  • Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle.
  • 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.

We have created a file named "apple-app-site-association" without an extension, but if navigate to "http://ourdomain.com/apple-app-site-association" we get a 404 file not found error.

Apple specifies not to add a .json to the filename.

We see another SO overflow answer describing configuration changes to IIS to serve files without extensions. But what is the trick to getting this file to be served properly from GoDaddy's Linux or IIS servers?

Upvotes: 0

Views: 2270

Answers (2)

Praxiteles
Praxiteles

Reputation: 6030

This is what worked for us.

We put this text in a file named "web.config" in our main web directory along with the apple-app-site-association file.

<?xml version="1.0" encoding="UTF-8"?>
 <configuration>
     <system.webServer>
         <staticContent>             
             <remove fileExtension=".xml"/>
      <remove fileExtension=".svg" />
      <remove fileExtension=".ttf" />
      <remove fileExtension=".eot" />
      <remove fileExtension=".woff" />
      <remove fileExtension=".json" />
      <remove fileExtension=".otf" />
      <remove fileExtension=".mp4" />
      <remove fileExtension=".zip"/>
      <remove fileExtension=".eps"/>
      <remove fileExtension=".pdf"/>
      <mimeMap fileExtension=".pdf" mimeType="application/pdf" />
      <mimeMap fileExtension=".zip" mimeType="application/zip"/>
      <mimeMap fileExtension=".eps" mimeType="application/octet-stream"/>
      <mimeMap fileExtension=".json" mimeType="application/json" />
      <mimeMap fileExtension=".otf" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <mimeMap fileExtension=".xml" mimeType="text/xml" />
      <mimeMap fileExtension="." mimeType="application/pkcs7-mime"/>
         </staticContent>
     </system.webServer>
 </configuration>

Of note, that properly serves the file without an extension - BUT - as we understand it - Apple still requires two other steps. (1) Your server must get an SSL certificate so it can serve that file by HTTPS (that is a ~$60/year purchase on GoDaddy); (2) Your server must also code-sign the apple-app-site-association file (that is a ~$150/year on GoDaddy for a downloadable certificate which can code sign files.)

Upvotes: 0

jrichau
jrichau

Reputation: 126

I was able to get this to work by adding an .htaccess file at the root level that contains:

<Files "apple-app-site-association">
  ForceType application/json
</Files>

Oddly, I could not get this to work if I tried to put the apple-app-site-association and the .htaccess files in the .well_known directory.

With this configuration, the validator here https://branch.io/resources/universal-links/ was all green and the links themselves worked.

Upvotes: 3

Related Questions