Enabling pretty URL's produces an InvalidCallException

After adding urlManager to my [font="Courier New"]main-local.php[/font] file, I get an InvalidCallException. My [font="Courier New"]/common/main-local.php[/font] look like this:

[color="#000080"]return [/color][b][

[/b][indent][color="#008000"]‘components’ [/color]=> [b][

[/b][/indent][indent][indent][color="#008000"]‘db’ [/color]=> [b][

[/b][/indent][/indent][indent] [color="#008000"]‘class’ [/color]=> [color="#008000"]‘yii\db\Connection’[/color][b],

[/b] [color="#008000"]‘dsn’ [/color]=> [color="#008000"]‘mysql:host=localhost;dbname=somedb’[/color][b],

[/b] [color="#008000"]‘username’ [/color]=> [color="#008000"]‘someuser’[/color][b],

[/b] [color="#008000"]‘password’ [/color]=> [color="#008000"]'somepass[/color][b],

[/b] [color="#008000"]‘charset’ [/color]=> [color="#008000"]‘utf8’[/color][b],

[/b] ],[/indent][indent] [color="#008000"]‘mailer’ [/color]=> [b][

[/b] [color="#008000"]‘class’ [/color]=> [color="#008000"]‘yii\swiftmailer\Mailer’[/color][b],

[/b] [color="#008000"]‘viewPath’ [/color]=> [color="#008000"]@common/mail’[/color][b],

[/b] [color="#808080"][i]// send all mails to a file by default. You have to set

[/i][/color][color="#808080"][i] // ‘useFileTransport’ to false and configure a transport

[/i][/color][color="#808080"][i] // for the mailer to send real emails.

[/i][/color][color="#808080"] [/color][color="#008000"]‘useFileTransport’ [/color]=> [color="#000080"]true[/color][b],

[/b] ],[/indent][indent] ],[/indent][indent] [color="#008000"]‘urlManager’ [/color]=> [b][

[/b][/indent][indent][indent] [color="#008000"]‘class’ [/color]=> [color="#008000"]‘yii\web\UrlManager’[/color],[/indent][indent] [color="#808080"][size=“2”]// Disable index.php[/size][/color][/indent][/indent][indent][indent][color="#808080"] [/color][color="#008000"]‘showScriptName’ [/color]=> [color="#000080"]false[/color][b],

[/b][/indent][/indent][indent][indent] [color="#808080"][i]// Disable r= routes

[/i][/color][/indent][/indent][indent][indent][color="#808080"] [/color][color="#008000"]‘enablePrettyUrl’ [/color]=> [color="#000080"]true[/color][b],

[/b][/indent][/indent][indent][indent] [color="#008000"]‘rules’ [/color]=> [color="#000080"]array[/color][b](

[/b][/indent][/indent][indent][indent][indent] [color="#008000"]’//’ [/color]=> [color="#008000"]’/’[/color][b],

[/b][/indent][/indent][/indent][indent][indent][indent] [color="#008000"]’/’ [/color]=> [color="#008000"]’/’[/color][b],

[/b][/indent][/indent][/indent][indent][indent] ),[/indent][/indent][indent][indent][font="Menlo"][size="3"]],[/size][/font][/indent][/indent][indent]];[/indent][indent]

[/indent]My [font="Courier New"]/backend/web/.htaccess[/font]:

[color="#000080"]RewriteEngine[/color][color="#000080"] [/color][color="#008000"][b]on

[/b][/color][color="#808080"][i]# If a directory or a file exists, use it directly

[/i][/color][color="#000080"]RewriteCond [/color][color="#008000"][b]%{REQUEST_FILENAME} !-f

[/b][/color][color="#000080"]RewriteCond [/color][color="#008000"][b]%{REQUEST_FILENAME} !-d

[/b][/color][color="#808080"][i]# Otherwise forward it to index.php

[/i][/color][color="#000080"]RewriteRule [/color][color="#008000"][b]. index.php

[/b][/color]

[size="2"][font="Arial"]The error, calling [/font][font="Courier New"]http://www.mytestsite.com/[/font][font="Menlo"]:[/font][/size]

I have an identical new project and it is working with the same settings. What am I missing here?

Edit: Using the [font="Courier New"]advanced template[/font].

What should be these rules?




'rules' => array(

'//' => '/',

'/' => '/',

),



I think that any double-dash will be converted to a single one. I’ve tried removing those rules and it still throws the Exception.

Also, I’ve just tried this:

As mentioned here: http://stackoverflow…ut-urlmanager-i

with the same result: [font="Courier New"]InvalidCallException[/font].

Check indentation, you are putting ‘urlManager’ outside ‘components’ attribute.

You’re right! Shame on me. It works now, thank you!!