Yii 2 enablePrettyUrl不起作用

时间:2017-02-08 11:36:23

标签: yii2

我创建了一个基本项目,并设置了enablePrettyUrl = true。默认模板运行良好,但是当我点击链接"关于"例如,我收到此错误:

未找到

在此服务器上找不到请求的网址/网站/。

我创建了一个.htaccess文件:

<VirtualHost *:80>
 ServerName        test.dev
  DocumentRoot      /xx/basic/web/

 <Directory "/xx/basic/web">
  Options         FollowSymLinks Includes
  AllowOverride   All
  Order           allow,deny
  Allow           from All
 </Directory>
</VirtualHost>

创建虚拟主机:

<?php

 $params = require(__DIR__ . '/params.php');

 $config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
    'request' => [
        // !!! insert a secret key in the following (if it is empty) -        this is required by cookie validation
        'cookieValidationKey' => 'yii2_rest',
        //Configurando o input via JSON.
        'parsers' => [
            'application/json' => 'yii\web\JsonParser',
        ]
    ],
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
    //Componente yii\web\User que gerencia o status de autênticação dos usuários.
    'user' => [
        'identityClass' => 'app\models\User',//Classe de identidade para o yii\web\User.
        'enableAutoLogin' => false, //Impede que o estado de autênticação seja guardado em cookie.
        'enableSession' => false, //O status de autênticação do usuário não deve ser mantido em sessão.
        'loginUrl' => null, //Força mostrar o erro 403 em vez de redirecionar para a página de login.
    ],
    'errorHandler' => [
        'errorAction' => 'site/error',
    ],
    'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        // send all mails to a file by default. You have to set
        // 'useFileTransport' to false and configure a transport
        // for the mailer to send real emails.
        'useFileTransport' => true,
    ],
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\FileTarget',
                'levels' => ['error', 'warning'],
            ],
        ],
    ],
    'db' => require(__DIR__ . '/db.php'),
    'urlManager' => [

        'enablePrettyUrl' => true, //Habilita URL's amigáveis
        'showScriptName' => false,
        'rules' => [
            [
                'class'=>'yii\rest\UrlRule',
                'pluralize'=>false,
                'controller' => 'api/default',
            ],
        ],
    ],
    'authManager' => [
        'class' => 'yii\rbac\PhpManager',
    ]
     ],
    'params' => $params,
    'modules' => [
    'api' => [
        'class' => 'app\modules\api\apiModule',
        ],
      ],
   ];

 if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
    'class' => 'yii\debug\Module',
    // uncomment the following to add your IP if you are not connecting       from localhost.
    //'allowedIPs' => ['127.0.0.1', '::1'],
];

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' => 'yii\gii\Module',

    //'allowedIPs' => ['127.0.0.1', '::1'],
   ];
  }
 return $config;

创建主机: 127.0.0.1 test.dev。

这是我的web.php:

<canvas baseChart 
          [data]="getDoughnutChartData()"
          [labels]="getDoughnutChartLabels()"
          [colors]="lineChartColors"
          [chartType]="doughnutChartType"
          [legend]="legend"></canvas>

但不要工作任何链接。我错了吗?

1 个答案:

答案 0 :(得分:1)

问题已解决。 我更改了httpd.conf文件

AllowOverride All