如何为使用Apache Tomcat服务器提供服务的APPLE APP SITE ASSOCIATION设置MIME类型?

时间:2018-10-31 07:45:32

标签: ios tomcat deep-linking ios-universal-links apple-app-site-associate

我在.well-known目录下有这个apple-app-site-association文件。当我在浏览器中打开URL时,可以正确显示JSON文件,但是如果我使用任何验证器进行验证,都会出现以下错误。

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用重写阀来设置内容类型。将阀门添加到META-INF中的context.xml中:

<Context>
    <Valve className="org.apache.catalina.valves.rewrite.RewriteValve" />
</Context>

现在将apple-app-site-association文件带有.json扩展名放在.well-known文件夹中。在WEB-INF中创建一个名为rewrite-config的文件,其内容如下:

RewriteCond %{REQUEST_URI} /.well-known/apple-app-site-association
RewriteRule .* /.well-known/apple-app-site-association.json

现在您访问https://host/.well-known/apple-app-site-association时,将以内容类型设置为application / json的方式交付json文件,这是默认的mime映射。