# Создание нового редиректа
# Example
- Создайте файл в - /var/www/keitaro/var/redirects/. Например,- /var/www/keitaro/var/redirects/custom_redirect.php.
- В файле создайте класс с аналогичным именем. Пример: 
<?php
namespace Redirects;
use Traffic\Actions\AbstractAction;
class custom_redirect extends AbstractAction
{
    protected $_name = 'CustomRedirect';     // <-- Имя редиректа
    protected $_weight = 100;                // <-- Для сортировки в списке редиректов
    public function getType()
    {
        return self::TYPE_REDIRECT;              // <-- Указывает на то, что это редирект 
    }
    protected function _execute()  
    {
        $url = $this->getActionPayload();
        
        $html = '<html>
        <head>
            <meta http-equiv="REFRESH" content="1; URL=\'' . $url. '\'">
            <script type="text/javascript">window.location = "' . $url . '";</script>
        </head>
        <body>
            The document has moved <a href="' . $url . '">here</a>
        </body>
        </html>';
    
        $this->setContentType('text/html'); // <-- Ставит 'text/html' как content type 
        $this->setStatus(200);              // <-- Задает 200 в HTTP ответ
        $this->setContent($html);           // <-- Ставит $html в ответ 
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Доступные методы
Смотрите PHP интерфейс AbstractAction.
