Pretty urls in yii2

  1. Make Sure mod_rewrite enable
  2. Create .htaccess file in /backend/web/.htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine on

    # If a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Otherwise forward it to index.php
    RewriteRule . index.php

  3. Go to your backend/config/main.php add urlManager in components

     ‘urlManager’ => [
    ‘class’ => ‘yii\web\UrlManager’,
    ‘enablePrettyUrl’ => true,
    ‘showScriptName’ => false




yii framework user config params

Reference Link here
echo Yii::app()->params->adminEmail;

If it is difficult to user above one create function for it.

function yiiparam($name, $default = null)
if ( isset(Yii::app()->params[$name]) )
return Yii::app()->params[$name];
return $default;