@arab789

YII. Настройка маршрутизации?

Адрес сайта вида 1.2.3.4/~abcd
Главная страница отображается корректно, а вот с остальными проблемы, при переходе на ссылку http://1.2.3.4/~abcd/директория - сервер пишет: The server can not find the requested page.
Подскажите как настроить маршрутизацию?

'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
                // стандартное правило для обработки '/' как 'site/index'
                '' => 'site/index',
                'user/<action:.*>'=>'user/<action>',
                                
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
                    'showScriptName' => false
		),
  • Вопрос задан
  • 179 просмотров
Пригласить эксперта
Ответы на вопрос 2
copist
@copist
Empower people to give
Вариант 1

'urlManager'=>array(
		'urlFormat'=>'path',
		'baseUrl' => '/~abcd', // <-- имя вашей директории, куда перенесён проект
		'rules'=>array(
				// стандартное правило для обработки '/' как 'site/index'
				'' => 'site/index',
				'user/<action:.*>'=>'user/<action>',
                                
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
		),
		'showScriptName' => false
	),


Вариант 2
server {
    listen   80;
    charset utf-8;

    set_real_ip_from 127.0.0.1;
    real_ip_header X-Real-IP;

    root /path/to/~abcd; # <-- полный путь к вашей директории, куда перенесён проект

    location / {
        index index.html index.php;
        try_files $uri $uri/ /index.php?$args;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        #let yii catch the calls to unexising PHP files
        set $fsn /index.php;
        if (-f $document_root$fastcgi_script_name){
            set $fsn $fastcgi_script_name;
        }

        # With php5-cgi alone:
        fastcgi_pass 127.0.0.1:9000;

        # With php5-fpm:
        #fastcgi_pass   unix:/tmp/php-fastcgi.sock;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fsn;
        #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fsn;
    }
}
Ответ написан
vyachin
@vyachin
Ищу работу
нужно baseUrl указать в конфиге www.yiiframework.com/doc-2.0/yii-web-urlmanager.ht...

'baseUrl' => '/~abcd'
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы