Exposed filters and taxonomy. How to make a redirect to a term page when exposed form submit? Let's say there are 2 vocabularies:


Sizes (S, M, L, XL)
Colors (Red, Green, Yellow)


pathauto sizes: /size/s, /size/m, ... pathauto colors: /color/red, /color/green, ...

There is a catalog - taxonomy/term/% view with the following filters:


Size 
Color


If we use a filter, then the url will be like this - ?field_size_tid=2&amp;field_color_tid=3 It's normal, when several fields are selected in the filter

But when one field is selected in the filter, the url will be like -
?field_color_tid=2 But in fact the ?field_color_tid=2 = /color/green

How to make an redirect to /color/green instead of ?field_color_tid=2 in this case after exposed form submit?
Here is the code that should work for your use case. Create a custom module and replace YOUR_CUSTOM_MODULE part:

function YOUR_CUSTOM_MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'views_exposed_form') {
    // Exclude cases when query contains 'field_color_tid'.
    if (strpos($_SERVER['QUERY_STRING'],'field_color_tid') === FALSE) {
      // Act only if query string contains 'field_size_tid'
      if (strpos($_SERVER['QUERY_STRING'],'field_size_tid') !== FALSE) {
        $selected_tid = $form_state['view']-&gt;exposed_input['field_size_tid'];
        // Check if such taxonomy term exists.
        $term = taxonomy_term_load($selected_tid);
        if (!empty($term)) {
          // Redirect to taxonomy page.
          $path_alias = drupal_get_path_alias('taxonomy/term/'.$selected_tid);
          drupal_goto($path_alias);
        }
      }
    }
  }
}