Reputation: 11932
I have configured nginx + uwsgi to serve foo.com, but foo.com/bar/ I want to serve it like bar.com
example: foo.com/bar/test/ = bar.com/test/
also I want to make bar.com robots not allowed.
any suggestion?
Upvotes: 2
Views: 874
Reputation: 12775
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
...
}
Upvotes: 0
Reputation: 174624
Assuming you have foo.com
configured as:
location / {
# your normal stuff
}
Something like this should work:
location / {
rewrite ^/bar/(.*)$ bar.com/$1? break;
}
For blocking robots, see this nginx forum entry.
Upvotes: 1