方法1 http://example.com/ - 前台 http://example.com/admin/ - 後台 指令如下 cd /path/to/project/frontend/web ln -s ../../backend/web admin Apache設定 <VirtualHost *:80> ServerName example.com DocumentRoot "/path/to/project/frontend/web" Options +FollowSymlinks ... </VirtualHost> Nginx設定 server { charset utf - 8 ; client_max_body_size 128 M ; listen 80 ; # # listen for ipv4 # listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name mysite . local ; root / path / to / project / frontend / web ; index index . php ; ... } 方法2 frontend/config/main.php 設定如下 .... ' components ' => [ .... ' request ' => [ ' baseUrl ' => ' ' , ] , ' urlManager ' => [ ' scriptUrl ' => ' /index.php ' , ] , // use the followin...