3

I have this scenario. I want to redirect in nginx all subdomains in this format.

(profile_name).mydomain.com mydomain.com/profile/(profile_name)

How can I do this in nginx?

Thanks.

1 Answer 1

2

You could use a regular expression server block.

server {
    server_name ~^(?<name>.+)\.example\.com$;
    return 301 http://example.com/profile/$name$request_uri;
}

See this document for details.

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.