如果新位置每隔几个月就会改变,我应该使用301还是302?

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.

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.