cakephp3 ads.txt 追加
色々と記事見たけどうまくいかなかったので、ここにメモ。 ルート直下に置け言われたけどフレームワークはやり方違うねんという事。
まずconfig/routes.phpのRouter::scope内に以下を追加
$routes->connect('/ads.txt', ['controller' => 'Ads', 'action' => 'ads'] );
んで、それに一致するcontroller, templateを作成
templateのファイルにははgoogle.com, pub~hogehoge~をコピって controllerはこんな感じ(AdsControllerになると思う)
public function ads() { $this->viewBuilder()->layout(''); $this->response = $this->response->withDisabledCache()->withType('text/plain'); }
ヘッダーフッターあるとダメそうなので、layout('')に デフォがtext/htmlをwithTypeで指定している。
多分日本語の記事ってないよね~て、っかするほどの事でもないんだと思う 精進あるのみ!