I have developed a module that creates a certain set of pages. What I would like to do is create a specific redirect for those pages if they are not found while keeping the generic Drupal 7 wide redirect for all other pages. Is this possible and how would I go about doing it?


  • Why would pages you have created not be found? Do you have something like myurl/<someID>, where not all possible <someID> values exist?
    – rooby
    Commented May 11, 2013 at 8:49
  • The pages are created depending on user actions. So in some instances the page may not exist yet and instead of displaying a 404, I would rather redirect them to the appropriate page.
    – user5013
    Commented May 13, 2013 at 15:37

3 Answers 3


I suggest to try the Redirect or rules module.


You can create URL redirects manually for each of these pages, but the Redirect module makes this much easier.

  • Go to "Configuration > Search and metadata > URL redirects > Fix 404 pages" (admin/config/search/redirect/404).

So, you can see that there are a few paths that I have tried to access that do not exist. Next, to each one there is an "Add redirect" operation.

  • Click "Add redirect"

When Clicking on "Add redirect" link we can specify where we would like users to be redirected when they reach the page that does not exist.

See more how to Fix 404 Pages Using redirect Module.

  • 1
    The rules module would be the best generic solution I think.
    – user5013
    Commented May 13, 2013 at 15:38
  • How can we can page not found event in Rules?
    – AgA
    Commented Aug 23, 2013 at 10:31
  • 1
    Can you expand this a little bit to describe how these two modules can solve the problem?
    – mpdonadio
    Commented Aug 23, 2013 at 11:10

You can try by going on "admin/config/system/site-information"page. There you can give links where to redirect on the "Default 403 (access denied) page" and "Default 404 (not found) page". For example if you type "node", it will take you to front page.


Create a Page in Page Manager where you use an HTTP response code and disable all form elements on that page.

Give your path a (random) name.

Set the Response code of the Page to: 404 Page not found.

Create a rule with Rules that:

  1. fires if a hidden field on your form is filled out OR if the email address has a certain TLD e.g. ".site"

  2. removes all roles and adds a role of e.g. "spammer"

  3. blocks them

  4. and redirects them to that Page path or a website that collects spammers (I'm not sure which one)

That's how I'd do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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