経緯

運用中のCakePHPで構築されたサイトに以下のエラーログが吐かれていた。

YYYY-MM-DD 15:31:28 Error: [MissingControllerException] Controller class Apple-touch-icon.pngController could not be found.
Exception Attributes: array (
  'class' => 'Apple-touch-icon.pngController',
  'plugin' => NULL,
)
Request URL: /apple-touch-icon.png
Stack Trace:
#0 /path_to/app/webroot/index.php(113): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}

これは iPhone、iPad 用のアイコンをダウンロードしようとしているリクエストなのだが、
どうも対応が入っていなかった模様・・なので忘れないようにメモ。

対応内容

少し検索して出てくるような対応は既に行われていた。

app/View/Layouts/default.ctp

<link rel="apple-touch-icon" sizes="180x180" href="/img/favicon.png">

でも実際に apple-touch-icon.png とか apple-touch-icon-120x120.png へのリクエストは飛んできている。
なので、少し強引だが mod_rewrite で無理やり飛ばす事にした。

.htaccess

RewriteEngine On
RewriteRule ^apple-touch-icon.*\.png$ /img/favicon.png [R=301,L]

もうこれで許して・・


トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2019-06-06 (木) 22:14:13 (1775d)