0

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 application/json content type in WordPress?

I tried to directly upload it, but it didn't work.

  • I tried to read about it, and I am not sure why is there anything unique about adding such a file for wordpress. what is the wordpress specific aspect here that is not just a webserver configuration that is not related to wordpress and therefor better asked on stack overflow? – Mark Kaplun Jul 29 '17 at 0:59
  • Note that this was also asked and answered at stackoverflow.com/questions/45390443/… – Tom J Nowell Jul 2 '18 at 15:17
1

OP moved this question to StackOverflow: https://stackoverflow.com/a/45399792/6471228

Answer via Alex Bauer:

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.