Config apple-app-site-association file with WordPress

Viewed 6393

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"

4 Answers

The easiest way to have the apple-app-site-association file delivered with content type application/json or application/pkcs7-mime in Apache is to add an .htaccess file in the same directory with the following contents:

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

or

<Files apple-app-site-association>
ForceType application/pkcs7-mime
</Files>

Then you don't have to add it to your server configuration.

Credit goes to http://redquark.com/wp/?p=209

In case anyone is in the same situation I was where my website is hosted on Bitnami WordPress (e.g. through AWS), your root directory path is /opt/bitnami/apps/wordpress/htdocs. Once you've copied your association file there, the place to make the configuration change for the content type header described in Alex's answer is /opt/bitnami/apps/wordpress/conf/httpd-app.conf. Finally, you'll need to restart Apache for the configuration change to kick in, using the command sudo apachectl -k graceful. You can verify that your setup is correct using this validator tool.

See my post here for more details.

I was able to upload the file after adding the following to wp-config.php file:

define('ALLOW UNFILTERED UPLOADS', true);

Now when I have the file uploaded I again removed the line for security reasons and I can further update the content of apple-app-site-association file through FTP.

Related