Пройдя учебник Yii, я сразу же столкнулся с проблемой. Я пытаюсь применить prettyURL к базовому проекту yii2.Невозможно применить prettyUrl для нового проекта Yii2
Это файл 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' => 'hCfpup7Utu5ddLMZQoJ6khEkQiwWlp1j',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'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'],
],
],
],
'urlManager' => [
'showScriptName' => false,
'enablePrettyUrl' => true
],
'db' => require(__DIR__ . '/db.php'),
],
'params' => $params,
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;
И это файл .htacces, что я создал в/веб-папки (где index.php есть):
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
Однако результат выглядит следующим образом:
Если я пытаюсь г о к другой странице:
Я уже вошел в httpd.conf XAMPP и изменил все AllowOverides на все и убедились, что
LoadModule rewrite_module modules/mod_rewrite.so
является раскомментировать.
Try добавление ' 'enableStrictParsing' => ложный,' файл ' 'urlManager'' конфигурации. – Brett
Спасибо за ваш комментарий. К сожалению, это не помогло решить проблему – Vlad