跳到主要內容

Yii2 advanced (前後台版本) 在單一網址中執行

方法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 128M;
 
    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 following, if you want to enable speaking URL for the frontend
//        'urlManager' => [
//            'enablePrettyUrl' => true,
//            'showScriptName' => false,
//        ],
    ],
backend/config/main.php

....
    'components' => [
        ....
        'request'=>[
            'baseUrl'=>'/backend',
        ],
        'urlManager'=>[
            'scriptUrl'=>'/backend/index.php',
        ],
        // use the following, if you want to enable speaking URL for the backend
//        'urlManager' => [
//            'enablePrettyUrl' => true,
//            'showScriptName' => false,
//        ],
    ],

Apache 設定 (.htaccess with mod_rewrite)
RewriteEngine On

# End the processing, if a rewrite already occurred
RewriteRule ^(frontend|backend)/web/ - [L]

# Handle the case of backend, skip ([S=1]) the following rule, if current matched
RewriteRule ^backend(/(.*))?$ backend/web/$2 [S=1]

# handle the case of frontend
RewriteRule .* frontend/web/$0

# Uncomment the following, if you want speaking URL
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([^/]+/web)/.*$ $1/index.php
Nginx設定
server {
    set $project_root /path/to/example.com;
    set $fcgi_server 127.0.0.1:9000;
    #set $fcgi_server unix:/var/run/php-fpm/example.socket;
 
    charset utf-8;
    client_max_body_size 128M;
 
    listen 80;
 
    server_name example.com;
    root $project_root/frontend/web;
    index index.php;
 
    access_log  /var/log/nginx/example.access.log combined;
    error_log  /var/log/nginx/example.error.log warn;
 
    location ^~ /backend {
        rewrite ^/backend(.*)$ /backend/web$1 last;
    }
 
    location ^~ /backend/web {
        root $project_root;
 
        # uncomment the following, if you want to enable speaking URL in the backend
        #try_files $uri $uri/ /index.php$is_args$args;
 
        location ~ /\.(ht|svn|git) {
            deny all;
        }
 
        location ~ \.php$ {
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass $fcgi_server;
        }
    }
 
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
 
    location ~ /\.(ht|svn|git) {
        deny all;
    }
 
    location ~ \.php$ {
        try_files $uri =404;
        include fastcgi_params;
        fastcgi_pass $fcgi_server;
    }
}
方法3 

使用SubDomain ...





留言

這個網誌中的熱門文章

透過 Docker 快速建立 openvpn 伺服器

此docker install安裝適用 ubuntu 16.04 18.04 如果已安裝docker-compose 那任何linux環境都可以使用 #sudo apt update #sudo apt install -y apt-transport-https ca-certificates curl software-properties-common #curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - #sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" sudo apt update apt-cache policy docker-ce sudo apt install -y docker-ce docker-compose sudo groupadd docker sudo usermod -aG docker ${USER} exit 然後再登入一次 接下來有安裝docker-compose 的機器都適用 mkdir ~/docker-compose cd ~/docker-compose nano docker-compose.yml -------請輸入以下內容 version: '2' services:     openvpn:         container_name: openvpn         image: kylemanna/openvpn         volumes:         - ./data:/etc/openvpn         ports:         - '1194:1194/udp'         cap_add:         - NET_ADMIN         restart: always ----------   # 請把200.200.200.200 改成你server的ip或domain name

完美同盟/Perfect League

完美同盟/Perfect League 時間  20-30MIN 人數  4 OR 6人 年齡  6歲以上 類型  卡牌 機制  Co-operative Play 合作遊戲、Hand Management 手牌管理、Memory 記憶、Trick-taking 牌組搭配 設計師  Way Of Change、ALex Tseng 美術  Tanner Lai 編輯  Bountiful Living 出版年 2016 遊戲基本介紹 想認識新朋友 (異性朋友),不可或缺的必備良藥! 3回合內玩出默契與互動,兩人一組充足的互動特性,讓原本尷尬與陌生的新朋友變的熱絡,在遊戲回合後自然而然讓兩人有更多的討論。 遊戲規則介紹 這是一款兩個人一組的默契遊戲,經由與隊友交換手牌,組合桌上公牌,搭配出最大牌型決勝負。遊戲過程主要是選牌(宣告)、交換手牌、出牌、組合牌型 四個步驟來進行,反覆直到有隊伍取得10分獲勝。 [ 準備階段 ] 4人遊戲時,先將特殊牌(花朵圖案)挑出,然後每人發11張手牌及2張特殊牌,同組玩家對坐且左右兩邊為其他Team的玩家 [ 回合開始 ] 回合開始時在場上開啟三張公用牌 [ 宣告(選牌) ] 參考桌上公牌,思考最佳牌組組合,起始玩家及起始玩家右手邊的玩家,需要選擇要選2張或是1張公牌來組合牌型,被選過的牌,另一隊也可以選擇。 [ 交換手牌 ] 選擇1張公牌的隊伍可以跟同伴交換3張手牌,選擇2張的隊伍只能交換1張手牌,藉由交換手牌暗示隊友如何出牌,過程不可提示牌組相關的訊息。(註:特殊牌不能交換) [ 出牌 ] 從起始玩家開始,順時針每人輪流出1張牌,每人需出2張牌,與隊友在桌上選好的公牌搭配(選2張的隊伍,可以選1張或2張公牌組合),組合成最大的5張牌牌組與敵隊比大,結算後含公牌(不含手牌)放入棄牌堆。 [ 結算 ] 每回合獲勝隊伍會得到2顆鑽石,第二名會得到1顆,1顆鑽石代表1分,紅寶石代表5分,可自行決定達標獲勝總分,培養最佳默契。(註:使用剩餘的牌繼續下一回合遊戲,最後剩3張(含特殊牌)遊戲結束。) 遊戲特別之處 1.只要10分鐘,將尷尬化為無形,就是這個遊戲最強的特別之處! 2.利用交換手牌加深雙方互動,組合不到牌組不要動怒,多點提示啦。 3.獨特的文青風格卡牌,每張卡

Raspberry Pi 3 B+ WiFi 無法連線問題

如果安裝目前最新版(2018-03-13)的映像檔開機後,會發現看不到WiFi 裝置。 sudo vi /etc/network/interfaces     最下面加上   ----------- allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf ----------- 存檔後執行 sudo systemctl enable wpa_supplicant.service     sudo vi /etc/wpa_supplicant/wpa_supplicant.conf     -----------   country=TW ctrl_interface=/var/run/wpa_supplicant network={ ssid="ssid" psk="password" }   -----------   sudo reboot now 存檔後重開後即可連線