Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Config apple-app-site-association file with WordPress

I’m trying to implement iOS Universal Links, I need to serve an apple-app-association file at the root of my WordPress.

How could I serve my apple-app-association file with Content-type: "application/pkcs7-mime" in WordPress?

I tried to directly upload it, but of course it didn't work because I need to modify the Content-type of the apple-app-association to: Content-type: "application/pkcs7-mime"

like image 910
DiegoQ Avatar asked Oct 15 '25 08:10

DiegoQ


1 Answers

Since the apple-app-site-association file is not a WordPress file, you have to configure the content type at the server level. This is different depending on environment (Apache vs. nginx, for example). This can be hard, if your host doesn't allow access to low level configuration.

Apache configuration

Modify the /etc/apache2/sites-available/default-ssl (or equivalent) file to include the snippet:

<Directory /path/to/root/directory/>
...
<Files apple-app-site-association>
Header set Content-type "application/pkcs7-mime"
</Files>
</Directory>

nginx configuration

Modify the /etc/nginx/sites-available/ssl.example.com (or equivalent) file to include the location /apple-app-assocation snippet:

server {
   ...
   location /apple-app-site-association {
      default_type application/pkcs7-mime;
   }
}

Source: https://gist.github.com/anhar/6d50c023f442fb2437e1#modifying-the-content-type

In theory I believe it is possible to do the Apache configuration via a .htaccess file, but I've never tried.

You may prefer to look into a free hosted deep link service like Branch (full disclosure: I'm in the Branch team) or Firebase Dynamic Links to handle all of this for you.

like image 159
Alex Bauer Avatar answered Oct 16 '25 21:10

Alex Bauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!