In this time, i will explain how to create pretty url in yii2,

we frequently use yii2 framework in many project of homework, like crud database,

first step open xammpp ,click start to apache and mysql start
and open folders in xampp select htdocs select basic, then access project in google with localhost / basic / web / index. php? r = items where item are the field in the database,

then access will display from the field item, where this url is the default url from yii2 next to create a pretty url, open a sublime open a file config in web. php we add a script to make a pretty url, first,type the script
where in the scription enable the pretty url

‘enablePrettyUrl’=> true,
‘showScriptName’ => false,
‘rules’=> [

after it makes a new file on the web folder, write the script like this

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php
where to rewriteengine where to change its like this

in the index file will rewrite, ok save ,file save with the name. htaccess,

after save open in google access url default and his display not item displays but display default diplays in yii2 because url was already changed in pretty url,


then try to replace / items then access url ,

pretty url successful can display data item.

where pretty url are very easy, and not too much paths written .