第一步:xampp在的根目录:
复制粘贴:下面的
# prevent directory listings Options -Indexes # follow symbolic links Options FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/admin/$ RewriteRule ^(admin)/$ /$1 [R=301,L] RewriteCond %{REQUEST_URI} ^/admin RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^(.*)$ /frontend/web/$1
第二步:在backend\web里面创建一个.htaccess文件(复制粘贴下来的代码)
第二步:在frontend\web里面创建一个.htaccess文件(复制粘贴下来的代码)
# use mod_rewrite for pretty URL support RewriteEngine on # if a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward the request to index.php RewriteRule . index.php
第三步:frontend\config\main.php文件中复制粘贴下面的代码;就行了
'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules'=>[ '/'=>'/', ], ]显示效果: