Apple touch icon isn't showing up on the home screen

杀马特。学长 韩版系。学妹 提交于 2019-11-30 07:57:21

I had the same problem. The solution is to remove the password protection on the website.

I put the same page and icon on two other sites and it worked perfectly, so I think maybe it might be because the original two test servers I was working on were password protected - although obviously I'd entered the credentials to browse the page, so not entirely sure why that would be a problem. However, the results appear to suggest this was the case.

In the Apple Safari Web Content Guide they suggest putting the icons in the "root document folder".

To specify an icon for the entire website (every page on the website), place an icon file in PNG format in the root document folder called apple-touch-icon.png or apple-touch-icon-precomposed.png.

I tried this and it wouldn't work until I finally moved the icons to an 'img' folder and linked to them there.

However, I suspect the reason the html5boilerplate icon worked and yours didn't was because you are using a virtual directory such as:

http://localhost/myvirtualdirectory/apple-touch-icon.png

while the default behavior of iOS is to look at the root domain even when you are hosting out of the virtual directory:

http://localhost/apple-touch-icon.png

Hopefully others could verify this.

I had the very same problem, and the source of the problem is that I had an htaccess file with password protection for my site, so the webclip icon will not work, to solve this problem and still have password protection you need to add this code:

SetEnvIf Request_URI "(/apple-touch-icon\.png)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

That way you have full access to http://www.example.com/apple-touch-icon.png without needing any password.

If you are still having problems here is an example with the full htaccess file:

AuthUserFile /home/mysite/.htpasswds/.htpasswd
AuthType Basic
AuthName "Password Protected"
Require valid-user
SetEnvIf Request_URI "(/apple-touch-icon\.png)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

That should fix the problem.

Cheers!!

I had the same problem when my icons were in my ui/img folder, even though my site wasn't password protected. After moving them to my root folder (and clearing the cache) it started working.

Placing an icon on the external image hosting and adding url as value of "href" worked for me as charm.

I couldn't get this to work until I went on my iPhone under Settings->Safari and then 'Clear History and Website Data' and then try and add it to my homepage.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!