tulis semula - Cari peraturan penulisan semula untuk nama domain diperibadikan nginx
phpcn_u1582
phpcn_u1582 2017-05-16 17:23:29
0
2
766

Idea:
http://abc.ccav.com tulis semula ke http://www.ccav.com/uid/abc
http://abc.ccav.com/article/index/index tulis semula ke http:// www.ccav.com/article/index/index/uid/abc
http://abc.ccav.com/article/index/show/id/1 tulis semula ke http://www.ccav.com/article/index /show/uid/abc/id/1
http://abc.ccav.com/shop/index/index tulis semula ke http://www.ccav.com/shop/index/index/uid/abc
http: //abc.ccav.com/shop/index/show/id/1 tulis semula ke http://www.ccav.com/shop/index/show/uid/abc/id/1
Saya sebenarnya mencubanya beberapa kali tetapi gagal, tolong beri saya nasihat

phpcn_u1582
phpcn_u1582

membalas semua(2)
大家讲道理

Selesaikan sendiri

server {
    listen 80;
    #rewrite_log on;
    #error_log /datas/logs/ccav_rewrite.log notice;
    server_name *.u.ccav.com;
    location ~ ^/(images|styles|scripts|uploads)/
    {
        proxy_redirect        off;
        proxy_set_header    Host   www.ccav.com;
        proxy_pass      http://127.0.0.1:80;
    }
    location / {
        set $uid default;
        if ( $http_host ~* "^(.*)\.u\.ccav\.com") {
            set $uid ;
        }
        rewrite ^/article/index/show/id/([0-9]+)/?$  /article/index/show/uid/$uid/id/ break;
        rewrite ^/article/index/index/?$  /article/index/index/uid/$uid break;
        rewrite ^/article/index/category/cid/([0-9]+)/?$  /article/index/category/uid/$uid/cid/ break;
        proxy_pass http://www.ccav.com;
    }
}

Ty80

Ini bukan menulis semula, ia harus dipanggil lompat, anda boleh melakukan 301, apabila $host = 'abc.ccav.com', ^/(.*)$ http://www.ccav.com/$1 kekal; Idea Itu sahaja

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan