0
私は基本的なプロジェクトを作成し、enablePrettyUrl = trueを設定します。デフォルトのテンプレートがうまく動作しますが、私は「について」リンクをクリックしたとき、たとえば、私は、このエラーが表示さ:Yii 2 enablePrettyUrl do work
要求されたURL /サイト
が見つかりませんを/については、このサーバー上に見つかりませんでした。RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
は、仮想ホストを作成します:
<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>
がホストを作成します。 127.0.0.1のtest.dev
私は.htaccessファイルを作成します。
これは私のweb.phpです:
<?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;
しかし、どのlink.Where、私は間違っていけない仕事?
は、あなたがウェブフォルダに.htaccessを入れているすべての? –
はい。しかし、役に立たなかった –
Apacheのmod_rewriteを有効にする –