Azure App Service中添加的apple-app-site-association文件无法访问
解决Azure App Service中无扩展名apple-app-site-association文件404问题
方案1:通过Kudu编辑现有web.config
即便应用是ACS生成的,仍可尝试通过Kudu控制台修改web.config:
- 访问
https://<你的App Service名称>.scm.azurewebsites.net登录Kudu - 进入
Debug console->CMD或PowerShell,找到站点根目录下的web.config - 在
<system.webServer>节点内添加以下规则,保存后重启App Service:
<staticContent> <mimeMap fileExtension="." mimeType="application/json" /> </staticContent> <rewrite> <rules> <rule name="apple-app-site-association" stopProcessing="true"> <match url="^.well-known/apple-app-site-association$" /> <action type="Rewrite" url="/.well-known/apple-app-site-association" /> </rule> </rules> </rewrite>
方案2:通过Azure门户配置全局MIME类型
无需修改web.config,直接在门户配置:
- 进入目标App Service -> 左侧菜单
配置->常规设置 - 找到
MIME类型区域,点击添加 - 输入:
- 扩展名:
. - MIME类型:
application/json
- 扩展名:
- 保存配置,等待应用重启后测试访问
方案3:通过Azure CLI配置MIME类型
用CLI命令快速配置:
az webapp config set --name <你的App Service名称> --resource-group <资源组名称> --mime-types '.'='application/json'
执行后重启应用:
az webapp restart --name <你的App Service名称> --resource-group <资源组名称>
方案4:验证文件路径与权限
- 确认文件准确位于
/.well-known/目录下,文件名完全为apple-app-site-association(无任何扩展名,可在Kudu中查看文件属性确认) - 检查文件权限:在Kudu中右键文件选择
Properties,确保权限为644或其他可读权限
内容的提问来源于stack exchange,提问作者David Shochet
相关产品推荐
相关产品推荐

