want to know how to change this
//localhost/yii2basic/web/index.
to this
First, set up a virtual host, like this - if using Apache:
<VirtualHost *:80>
DocumentRoot "/path/to/localhost/yii2basic/web/"
ServerName local.yiiframework.com
<Directory "/path/to/localhost/yii2basic/web/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then, enable pretty URLs in config/web.php;
// components
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
]
Then, finally, drop a .htaccess file in yii2basic/web:
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
All of that will ensure that the basic Yii2 application is served out of the ‘web’ directory, and the URL that people see will be the ‘localhost/yii2basic’ or whatever you have set up in /etc/hosts.