我试图从我的iOS应用程序中实现通用链接,因此我需要拥有" apple-app-site-association"文件位于我的网络服务器的根目录。
我使用的是nginx,所有内容(应该)设置正确。我的网站工作,PHP工作,我的api工作。唯一的问题是,当我去我的网站" test.com/apple-app-site-association"浏览器(以及iOS浏览器)下载文件而不是仅显示它,从而使我的通用链接不起作用。
如果有人对如何阻止nginx提供网站下载并提供服务有任何想法,我会很高兴。
以下是我的服务器配置,我的网站已被删除:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name test.com www.test.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
include snippets/ssl-test.com.conf;
include snippets/ssl-params.conf;
client_max_body_size 1m;
root /var/www/test.com/web;
index index.html index.htm index.php;
access_log /var/log/nginx/test.com.access.log;
error_log /var/log/nginx/test.com.error.log;
#Default url rewrites
location / {
#root /var/www/test.com/web;
try_files $uri $uri/ /index.html;
autoindex off;
index index.html index.htm index.php;
}
location ~ \.php$ {
# try_files $uri =404;
set $path_info $fastcgi_path_info;
root /var/www/test.com/web;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
try_files $uri $uri/ /index.php$is_args$args;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param APP_ENV dev;
}
#Apple universal links
location = /apple-app-site-association {
default_type application/pkcs7-mime;
}
#Redirect all requests under /user/ to the "get App" page
location /user/ {
return 301 https://test.com/get_app.html;
# try_files $uri $uri/ /get_app.html;
}
#Let's Encrypt SSL Validation
include snippets/letsencrypt.conf;
}
使用REST API客户端,请求该文件会显示以下标题,这些标题看起来是正确的(没有"附件"标题):
Server: nginx/1.10.3
Date: Sun, 02 Apr 2017 17:25:42 GMT
Content-Type: application/pkcs7-mime
Content-Length: 149
Last-Modified: Sun, 02 Apr 2017 16:07:02 GMT
Connection: keep-alive
Etag: "58e121a6-95"
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Accept-Ranges: bytes
答案 0 :(得分:0)
您的浏览器和ios浏览器可能不支持Content-Type: application/pkcs7-mime
。如果内容是人类可读的,请尝试设置Content-Type: text/plain
。
另请参阅this link是否有任何帮助。