Answer the question
In order to leave comments, you need to log in
How to enable pretty url yii2?
Hello everyone ,
I'm doing a rest api on the yii2-basic template , the task was to upload what was done to the hosting
, it's worth making a reservation that openserver is installed on the LAN and the local domain "looks" in the web
folder
and pretty url work,
but on the hosting the site gives an error exception 'yii\web\ NotFoundHttpException' with message 'Page not found.' in /api/vendor/yiisoft/yii2/web/Request.php:284
If the url manager is turned off, then everything on the hosting works, so the problem may be in the
config manager looks like this:
$config = [
'id' => 'api-artpix',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'request' => [
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
'response' => [
'formatters' => [
'json' => [
'class' => 'yii\web\JsonResponseFormatter',
'prettyPrint' => YII_DEBUG,
'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
],
],
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => false,
'enableSession' => false,
],
'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' => $db,
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
'create' => 'order/create',
'<controller:\w+>/<action:\w+>/' => '<controller>/<action>'
],
],
],
'params' => $params,
];
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(web)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /web/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question