Hello all,
my issue is that \Yii::$app->urlManager->createAbsoluteUrl() and \Yii::$app->urlManager->createUrl() include the script name in my links.
fe. a link created with the config below is "/index.php/_res/img/1.html".
I have no problem with my .htaccess file, because even if I remove the ‘index.php’ part from the url and hit the link I still get the result I am expecting to, which is just a static message for now.
Anyway, why the scriptname shows even if the showScriptName is set to false?
My config is below and thanks for the help.
<?php
return [
//config ovverides
//Default controller
'defaultRoute' => 'home',
//Normal configuration
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'suffix' => '.html',
'rules'=>[
'_res/img/<id:\d+>/'=>'resource/img',
],
],
//custom components
'mobiledetect' => [
'class' => '\app\components\MobileDetect',
],
'assetManager' => [
'bundles' => [
'yii\web\JqueryAsset' => false,
'yii\bootstrap\BootstrapAsset' => false,
],
],
//original components
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'gHwhtKJjsgYl_cIi7Ezr5S2-0ljjDtu6',
],
'view' => [
'theme' => [
'pathMap' => ['@app/views' => '@app/themes/basic'],
'baseUrl' => '@web/themes/basic',
],
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'error/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_ENV ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
],
];