1

As many others I am trying to implement universal links into my app.

I am using one.com as my webhotel provider, and have configured an apple-app-site-association json file without the json file ending.

Initially, I had troubles with strange characters appearing and the infamous content/type fault. I added this snippet to my .htaccess file as follows that solved that issue:

<Files "apple-app-site-association">
ForceType 'application/json'
</Files>

Below is the entire .htaccess code:

# Generated by One.com Website Builder
# Begin

<Files "apple-app-site-association">
ForceType 'application/json'
</Files>

RewriteEngine on

# Enforce SSL
# Handle non-www URLs
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^studievenn\.no [NC]
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Handle www URLs
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.studievenn\.no [NC]
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Handle URLs without .html extension
RewriteCond %{REQUEST_METHOD} ^(GET) [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}.html -f
RewriteRule ^(.*) $1.html [L]

# End
# Generated by One.com Website Builder

Here is the aasa validator response

enter image description here

I am primarily struggling with the

Your server returned an error status code (>= 400)

Fault, but also the two latters errors.

What could be the issue here?

Erik
  • 2,500
  • 6
  • 28
  • 49

2 Answers2

3

I solved this problem by rather placing the apple-app-site-association file in a subdirectory: /.well-known/apple-app-site-association instead of my document root. This fixed the issue.

Erik
  • 2,500
  • 6
  • 28
  • 49
  • Since that is where you are _supposed_ to put the file, it's hard to see how this is interesting. – matt Aug 21 '20 at 16:33
  • @matt According to Apple [here](https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html), you can choose to either put the file at the root, or in the .well-known directory: **"Upload the apple-app-site-association file to your HTTPS web server. You can place the file at the root of your server or in the .well-known subdirectory."** So I do find it a perfectly reasonable question. – Erik Aug 21 '20 at 19:28
  • 1
    OK good point! However, there are universal links features that work _only_ if you keep the file in the `.well-known` directory, so that should be considered the "right" place. I suspect that in fact Apple will eventually say that it's the only acceptable location. – matt Aug 21 '20 at 19:33
  • By the way, getting your `.htaccess` to allow the association file to be seen can be a tricky business. You can see me asking about it here: https://stackoverflow.com/questions/63456352/see-apple-app-site-association-file-in-well-known-directory-despite-rewritecond There might be something in anubhava's answer that's useful to you. – matt Aug 21 '20 at 19:34
  • @matt sorry for late reply. I see that the .well-known directory makes the most sense, and it does also seem like the cleanest solution. However at the time, it didnt make much sense to create another subdirectory for the sole purpose of one file - felt like I was overcomplicating a rather simple thing. I'll look into the .htaccess file. This was the only way I made it work, but I'm sure there are better solutions. – Erik Aug 24 '20 at 11:14
0

you should add this end of the htaccess file it worked form me

Header set Content-type "application/pkcs7-mime"