php - Should I Use 301 or 302 If the New Location Is Changing Every Few Months

647

Page X redirects to page Z.

URL of page X doesn’t change.

URL of page Z does change.

Should I use 301 or 302 if the new location is changing every few months?

NOTE: I redirect using PHP.

896

Answer

Solution:

In short, 301 redirects are permanent, and 302 redirects are temporary. 301 redirects tell the search engines that the old location is to be removed from their index and replaced with the new location. On the other hand, a 302 redirect says that you’ve moved a page or domain but only temporarily and the original page will ultimately be reestablished.

Also, as said in the comments, if a browser finds 301 status code, it might map the old URL with the new URL, and might not request the original location from the next time unless cache is removed and that would redirect your visitors to a non-existent page.

In this case, it sounds like the second URL is not permanent, so just use 302.

People are also looking for solutions to the problem: fwrite - f(write) php doesn't seem to work

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.