Please add the following lines in ‘.htaccess’ file inside the ‘web’ directory of yii2.0 application.
在YII front /web 下面建立 .htaccess 在cmd 里面找到路径: echo>.htaccess
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
在: main.php 文件里面写入:
.................
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
),
],
.................
||||||||||||||||||
或者:在APACHE 里面:
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/test.dev/frontend/web"
ServerName test.dev
<Directory "E:/xampp/htdocs/test.dev/frontend/web">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
#RewriteEngine on
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . index.php
# DirectoryIndex index.php #####加入 # 号部份
</Directory>
</VirtualHost>