How to change the field name in the url when using views exposed sort? I've read a few posts on this and there does not seem to be an answer to that, is that right?

My exposed filters allow the user to change the sorting, but the url is kinda bad:

?sort_by=field_rating instead of just ?sort_by=rating, for instance. Can this be achieved somehow? Is it advisable to try out better exposed filters module when you have already kind of customized your exposed filters? /:
For order_by filter you can just set the filter identifier:



Although there is no option to set the identifier for sort_by filter, you can achieve your goal by altering the form.

Example

/**
 * Implements hook_form_alter().
 */
function YOURMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {

  if ($form['#id'] == 'YOUR-FORM-ID') {

    // fields which you want to rename
    $form_state['my_custom_names'] = array(
      'field_rating_value' =&gt; 'rating'
    );

    // rename option values
    foreach ($form_state['my_custom_names'] as $name =&gt; $new_name) {

      $form['sort_by']['#options'][$new_name] = $form['sort_by']['#options'][$name];
      unset($form['sort_by']['#options'][$name]);  

      if ($form_state['input']['sort_by'] == $name) {
        $form_state['input']['sort_by'] = $new_name;
      }
    }

    // the custom submit handler need to be fired before the original one
    array_unshift($form['#submit'], 'my_custom_exposed_form_submit');  
  }
}

/**
 * An additional submit handler for exposed filters.
 */
function my_custom_exposed_form_submit(&amp;$form, &amp;$form_state) {

  // set the form state values to their original names.
  foreach ($form_state['my_custom_names'] as $name =&gt; $new_name) {
    if ($form_state['values']['sort_by'] == $new_name) {
      $form_state['values']['sort_by'] = $name;
    }
  }
}


Make sure to replace YOURMODULE and YOUR-FORM-ID with proper names.