How to remove index.php from URL in Yii2

Please add the following lines in ‘.htaccess’ file inside the ‘web’ directory of yii2.0 application.

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

Go to config/web.php add edit urlManager

'urlManager' => [		
  'class' => 'yii\web\UrlManager',
  // Disable index.php
  'showScriptName' => false,
  'enablePrettyUrl' => true,
  'rules' => array(),
],

 

Add a Comment

Your email address will not be published. Required fields are marked *