2012-04-27 58 views
1

我已經配置的nginx + uwsgi服務foo.com具體的Django的URL路徑,但foo.com/bar/我想成爲像bar.com如何配置Nginx服務與另一個域

例如: foo.com/bar/test/ = bar.com/test/

我也想讓bar.com機器人不被允許。

有什麼建議嗎?

回答

1

假設你已經foo.com配置爲:

location/{ 
# your normal stuff 
} 

像這樣的東西應該工作:

location/{ 
    rewrite ^/bar/(.*)$ bar.com/$1? break; 
} 

阻止機器人,看this nginx forum entry

0
server { 
    listen 80; 
    server_name foo.com; 
    root /full/server/path/to/foo/folder; 
    index index.html index.php; 
    # This redirects anyone that directly types "foo.com/bar/xyz to bar.com/xyz" 
    if ($request_uri ~ ^/bar(.*)$) { 
     return 301 http://bar.com$1; 
     # Alternative for old nginx versions 
     # rewrite^http://bar.com$1 redirect; 
    } 

    # foo.com location blocks go below 
    ... 
} 

server { 
    listen 80; 
    server_name bar.com; 
    root /full/server/path/to/foo/bar/folder; 
    index index.html index.php; 

    # bar.com location blocks go below 
    ... 
}