Config apple-app-site-association file with WordPress

£可爱£侵袭症+ 提交于 2020-05-14 07:24:02

问题


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"


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/45390443/config-apple-app-site-association-file-with-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!