Clean URL

I’ve got clean urls in place in yii 1.1.

My .htaccess is configured and it is the same in both versions.

My url config rules are the same in both versions.


In yii 1.1 I can call an action this way:


(i use a suffix…)

While in Yii2 it only works if I call it like this:


I like the first form better.

is there a way I can have the same kind of url as in Yii 1?

What am I doing wrong?

After a litle more digging I found a config in my config.php in Yii 1 that goes like this:


Yet, the problema still remains.

It seems this setting doesn’t exist in Yii2.

Anyone knows what is the equivalent setting in Yii2?

Thank you in advance.

Have you read the documentation?

Of course I did. Still don’t getting it. That’s why I posted this topic!

Thank you for your answer anyway.

Hello jorge sequeira,

You need to add 2 htaccess files here

  1. htaccess file to -> root web folder with content

Options -Indexes

<IfModule mod_rewrite.c> 

  RewriteEngine on

  RewriteCond %{REQUEST_URI} !^public

  RewriteRule ^(.*)$ web/$1 [L] 


# Deny accessing below extensions

<Files ~ "(.json|.lock|.git)">

Order allow,deny

Deny from all


# Deny accessing dot files

RewriteRule (^\.|/\.) - [F]

  1. htaccess file to -> web/ folder with content

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule . index.php

Final is adding to config/web.php

'urlManager' => [

            'enablePrettyUrl' => true,

            'showScriptName' => false,

            'baseUrl' => '/yii2',

            'rules' => [

       		//your rules here



'request' => [

            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation

            'cookieValidationKey' => 'abc0123456789',

            'baseUrl' => '/yii2',


Note : /yii2 is folder contain your site.

And you can access your site as your rules