Prithviraj Mitra
Prithviraj Mitra

Reputation: 11812

301 redirect in nginx

I am trying to redirect a url from one domain to another domain in nginx.

URL 1 - http://domain1/event/ert123

URL 2 - http://domain2/event/dfe456

I have used the following code but doesn't work.

   #Test event
   location /event/ert123 {
        return 301 http://domain2.com/$request_uri
   }

Any help is highly appreciated. Thanks in advance.

Upvotes: 0

Views: 61

Answers (1)

Oleg Kuralenko
Oleg Kuralenko

Reputation: 11553

Why $request_uri? Maybe something like this?

  location /event/ert123 {
        return 301 http://domain2.com/event/dfe456
   }

Upvotes: 1

Related Questions