使用 WordPress 配置 apple-app-site-association 文件 [英] Config apple-app-site-association file with WordPress

查看:50
本文介绍了使用 WordPress 配置 apple-app-site-association 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现 iOS 通用链接,我需要在我的 WordPress 的根目录中提供一个 apple-app-association 文件.

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

如何在 WordPress 中使用 Content-type: "application/pkcs7-mime" 提供我的 apple-app-association 文件?

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

我试过直接上传,当然不行,因为我需要修改apple-app-association的Content-type为:Content-type: "application/pkcs7-mime"

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"

推荐答案

由于 apple-app-site-association 文件不是 WordPress 文件,您必须在服务器端配置内容类型等级.这取决于环境(例如 Apache 与 nginx).如果您的主机不允许访问低级配置,这可能会很困难.

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.

修改/etc/apache2/sites-available/default-ssl(或等效文件)以包含代码段:

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 配置

修改/etc/nginx/sites-available/ssl.example.com(或等效文件)以包含位置/apple-app-association 片段:

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;
   }
}

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

理论上我相信可以通过 .htaccess 文件进行 Apache 配置,但我从未尝试过.

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

您可能更喜欢查看免费托管的深层链接服务,例如 Branch(完全披露:我在分支机构团队)或 Firebase 动态链接为您处理所有这些.

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.

这篇关于使用 WordPress 配置 apple-app-site-association 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆