Home  >  Q&A  >  body text

nginx - Use 301 redirect to change the website to a new domain name and POST is lost

What should I do if using 301 redirection to change the website to a new domain name and get is effective, but post will become invalid and become get?

PHP中文网PHP中文网2713 days ago842

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-16 17:15:58

    Thanks for the invitation.
    The current method I can think of is in DNS

    New domain name cname Old domain name
    Old domain name A record Server IP

    It may not be very appropriate, I hope it helps.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 17:15:58

    Post will be ok if you change it to a relative domain name.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 17:15:58

    For the 301 response, the browser’s behavior is to send the URL in the GET request Location.
    If you need to keep the original POST method unchanged and re-request, you need to use 307, but this may not be what you want, because according to standard browsers, POST requests for 307 require explicit confirmation from the user (for example, an alert will pop up).
    For detailed explanation, please refer to the following two articles:

    1. http://www.alanflavell.org.uk...

    2. http://programmers.stackexcha...

    reply
    0
  • Cancelreply