我已经配置了 nginx + uwsgi 来服务 foo.com,但是 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
...
}