Commit ddd0f5b9595a0fc62cd56edad545aa4a6f0b7495
1 parent
a40d5f4b
robots txt
Showing
5 changed files
with
17 additions
and
7 deletions
Show diff stats
.gitignore
.htaccess
... | ... | @@ -16,7 +16,7 @@ AddDefaultCharset utf-8 |
16 | 16 | RewriteRule ^admin(.*) /backend/web/$1 [L] |
17 | 17 | |
18 | 18 | RewriteCond %{REQUEST_FILENAME} robots.txt |
19 | - RewriteRule . /frontend/web/index.php [L] | |
19 | + RewriteRule . robots.txt | |
20 | 20 | |
21 | 21 | # if a directory or a file of the uploads folder exists, use the request directly |
22 | 22 | RewriteCond %{REQUEST_URI} ^/storage | ... | ... |
backend/controllers/SettingsController.php
... | ... | @@ -76,11 +76,21 @@ |
76 | 76 | */ |
77 | 77 | public function actionRobots() |
78 | 78 | { |
79 | + /** | |
80 | + * @var Settings $model | |
81 | + */ | |
79 | 82 | $model = $this->findSettings(); |
80 | 83 | $model->scenario = Settings::SCENARIO_ROBOTS; |
81 | - | |
84 | + | |
85 | + $robotsTxt = fopen(\Yii::getAlias("@frontend/web/robots.txt"), "w+"); | |
86 | + | |
82 | 87 | if ($model->load(\Yii::$app->request->post()) && $model->save()) { |
83 | - \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved')); | |
88 | + | |
89 | + if (fwrite($robotsTxt, $model->robots)){ | |
90 | + \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved')); | |
91 | + fclose($robotsTxt); | |
92 | + } | |
93 | + | |
84 | 94 | } |
85 | 95 | |
86 | 96 | return $this->render( | ... | ... |
backend/web/robots.txt deleted
frontend/web/robots.txt