foo.comを提供するようにnginx+uwsgiを構成しましたが、foo.com /bar/をbar.comのように提供したいと思います
例:foo.com/bar/test/ = bar.com/test/
また、bar.comロボットを許可しないようにしたい。
なにか提案を?
foo.com
次のように構成したと仮定します。
location / {
# your normal stuff
}
このようなものが機能するはずです:
location / {
rewrite ^/bar/(.*)$ bar.com/$1? break;
}
ロボットのブロックについては、このnginxフォーラムのエントリを参照してください。
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
...
}