Support » Plugin: Redirection » Restrict redirect to 404s?

  • Resolved bjornhermans

    (@bjornhermans)


    Is it possible to make a redirect trigger only after a 404 has occured? Or can this functionality be added?

    I have certain redirects that I ONLY want to be activated if we are coming from a 404 error. However, currently all redirects work for all URLs (as you can also create a redirect to change the URL of an existing/valid page request).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author John Godley

    (@johnny5)

    I have certain redirects that I ONLY want to be activated if we are coming from a 404 error

    This doesn’t really make a lot sense. What are you trying to achieve? Why do you have redirects that you don’t want to be activated?

    Thread Starter bjornhermans

    (@bjornhermans)

    I want to catch requests to URLs that look like WordPress URLs but aren’t.
    An example would be a request to “/admin-db.php”. This page does not exist, but “/wp-admin/admin-db.php” does, and is a valid request.

    I have a lot of 404s that are requested by bots trying to probe my WordPress site(s).
    I want to have a rule that redirects any 404 requests to “/admin-db.php” (so “.*/admin-db.php.*” when specified as a regular expression) to “/” with a 301. So they no longer polute my 404 logs.
    However, because I am not able to mark this rule as “only apply when we come from a 404”, this rewrite would also break valid requests to “/wp-admin/admin-db.php”.

    Plugin Author John Godley

    (@johnny5)

    Personally I don’t think it’s worth redirecting bots or those kind of requests. It has no effect on the bots and just makes work for you and your site. They are best ignored.

    You can use the ‘group by’ dropdown on the 404 page to highlight important 404s.

    If you still want to implement the redirect then you would be better modifying the regular expression so it doesn’t match the valid URLs. Alternatively you can create ‘do nothing’ redirects to exclude certain URLs.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.