1

I have an old site on archive.mysite.com and new site on mysite.com. Archive has some old custom CMS and it will take some time to transfer old articles to new site, so for the time being I'd like to do the following :

  1. User types in some URL e.g. mysite.com/someRandomURL
  2. If URL doesn't exists I don't throw 404 immediately but first check if I can fetch content from mysite.com/someRandomURL in the background.
  3. If I can, than I serve that raw HTML that I've fetched from my archive (and I don't want wordpress sending 404 status in response header)
  4. If I can't than I finally throw 404 and let wordpress show 404 page.

I know this is hacky solution but I'm doing it with a reason so please don't comment on that.

Essentially, what I want to do is say "Let me check if this content 'really' doesn't exist, or if I maybe have it in my archive."

1

In WP, the 404.php template is used if a page is not found. If 404.php is not in your theme, then a generic Not Found is returned.

Make a child theme (since you never want to change theme code directly), then copy the 404.php file from the theme folder into your child theme folder. Then change that child theme 404.php to do what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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