How to serve 404s for non existent views paths with facets Is it possible have non-existent views paths 404, but to allow facets and parameter searches?

Most of the answers to this question for base views, are either for Drupal 6, or use Mikeytown's excellent Views404 module.

However this isn't an option if you're using faceted search. Using Views404 will return 404s for all of your faceted pages. 

Is there a general way to catch when views isn't hitting a facet or an allowed parameter?
The solution here was to alter the Views404 module. 

The module works by running a single hook_views_pre_view. This function runs a series of tests and if none of them pass returns a 404.

I added in an extra set of tests which would pass on my facets and so avoid the 404.

This problem doesn't exist with all facets. The problem comes because I'm using Facet API Pretty Paths. It turns:

https://mysite/view?f[0]=host_entity_node%253Afacet_label%3Afacet_value


Into:

https://mysite/view/facet_label/facet_value


And while views404 will allow para-metered search, it won't allow folders unless they pass one of the tests.

I altered my facet pretty paths in the UI, so one of the labels was country and all the rest began with 'filter':

e.g. 


Country Facet: Pretty path alias = country
Every other facet: Pretty path alias = filter_x


I then added the following code to views 404

$args_passed = 0;
foreach($args as $arg) {
  if($arg == 'country') {
    $args_passed++;
  } elseif(is_int(strpos($arg, 'filter'))) {
    $args_passed++;
  }
}

if($args_passed == (count($args)-1)/2) {
  return;
}


Facets always come in pairs, so it goes through every arg and looks for either country or filter. If if finds half of the url arguments are facet_labels then that's a pretty strong indicator this is a genuine path and shouldn't throw a 404.