2

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

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
    ...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.