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
    </IfModule>

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

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

 

 

Yii2 gii permission with IP


In Your backend/config/main-local.php change below line

$config['modules']['gii'] = 'yii\gii\Module';

With below code

$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
"allowedIPs" => ['127.0.0.2', '::1', '192.168.0.*', '192.168.178.20']
];

This is global change
Go To : vendor/yiisoft/yii2-gii/Module.php to include the remote IP as

public $allowedIPs = ['127.0.0.1', '::1', '192.168.1.*'];