Search code examples
iisweb-configapple-app-site-associate

What web.config setting will allow apple-app-site-association to be served?


I have added the apple-app-site-association file to the root of a website, but IIS is not delivering the file.

What is the best way to make the server serve this specific file without a file extension? Is there a way within a web.config to explicitly say "serve this file"?


Solution

  • I was having the same issue and found this amazing post:

    Serving apple-app-site-association from IIS IIS only serves files of known types, defined by their file extension. Since apple-app-site-association doesn’t include a file extention, IIS throws a 404 error, when I try to open it with a browser. I fixed this by adding a mimeMap in the web.config file:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <!-- required for apple-app-site-association: -->
          <mimeMap fileExtension="." mimeType="application/json" />
        </staticContent>
      </system.webServer>
    </configuration>
    

    If the above solution does not work, then add the following rule Create a rule in the "web.config" file, which will provide the JSON value when the Applebot robot crawls your site for the apple association

    <rewrite>
      <rules>
        <rule name="apple_json_file">
                    <match url="^apple-app-site-association" />
                    <action type="Rewrite" url="apple-app-site-association.json" />
                </rule>
      </rules>
    
    </rewrite>
    

    Add this section in system.webServer