A fresh mix of code snippets and tutorials

.htaccess for Apple Touch Icons

Devices and bots are often searching for different versions of the Apple Touch Icon. Here is a quick slice of .htaccess to redirect all apple-icon requests to apple.png.

Instead of dealing with countless 404 errors for missing apple icons such as apple-touch-icon-precomposed.png and apple-touch-icon-72x72.png, upload a single apple.png file and then add this snippet to your site’s root .htaccess file:

RedirectMatch 301 /apple-touch-icon(.*)?.png /apple.png

Note: the apple.png file should be uploaded to the site’s root directory.


I changed the name of my apple icon from apple.png to apple-touch-icon.png. Here is the new .htaccess rule that I use to redirect all requests for apple icons:

RedirectMatch 301 (?i)/apple(-touch-icon-.*)?.png /apple-touch-icon.png

This will redirect all requests for apple.png and/or any variation of apple-touch-icon-whatever.png to the file, apple-touch-icon.png. Note that apple-touch-icon.png should be located in the root directory of your site. Also note that this technique is case-insensitive, as instructed by the prepended (?i) modifier.


To see some examples of this code in action, try the following URLs:

  • https://wp-mix.com/apple.png
  • https://wp-mix.com/apple-touch-icon.png
  • https://wp-mix.com/apple-touch-icon-precomposed.png
  • https://wp-mix.com/apple-touch-icon-72x72.png
  • https://wp-mix.com/apple-touch-icon-114x114.png
  • https://wp-mix.com/apple-touch-icon-114x114-precomposed.png
  • https://wp-mix.com/some-crazy/path/apple-touch-icon-whatever.png

Learn more

.htaccess made easy