Forum Academy Marketplace Showcase Pricing Features

How to throw 404 error from dynamic pages

Hi,

I have few user profile pages which are created dynamically. So, I have one parent page for them and each of those pages are created on the basis of parameter passed to them.

When user is in “inactive” state, I want the profile page to return 404 error.

I don’t want to do following:

  • Redirect the page to some other page by checking user status in “on page load”
  • Change content of page to something generic which says “This user is inactive…”

That is because both of these are not SEO friendly behaviours. I just want to throw either 404 or 302 error from server side. How do I achieve that?

Thanks,
Mukesh

1 Like

I have the same question. This is what my SEO person said about why this is bad practice

A page that’s not found does a redirect to the /search page, which is returning an http 200 code. Why does this matter? What you’re doing today mimics the behavior of an old black-hat trick to generate doorway pages on the fly. Google will test you on this regularly by fabricating a URL they know doesn’t exist on your site and trying to fetch that URL.

I agree. When a page has a type A set and when we send a data A1 to this page, the user should be directly redirected to the 404 page if the data A1 does not exist.

I have the same problem using slugs… You can type your URL adding a slug word not existing in your database, the page will load but will be empty (or at least will not contain data linked to the slug). So yes, we can add some checks but it’s not really food for SEO yes, but also for the user experience.

I “think” a check could be not so difficult add to verify that the data passed to a page really exists…

Hey guys, I have the same problem and it looks like this wasn’t resolved.

Is there any way to redirect users to the 404 when they enter a dynamic URL that doesn’t exist?