Index: apachesolr_search.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v
retrieving revision 1.1.2.6.2.68
diff -u -r1.1.2.6.2.68 apachesolr_search.module
--- apachesolr_search.module	9 Feb 2009 14:12:22 -0000	1.1.2.6.2.68
+++ apachesolr_search.module	23 Feb 2009 14:08:59 -0000
@@ -351,6 +351,9 @@
         $initial_limits = variable_get('apachesolr_facet_query_initial_limits', array());
         $limit_default = variable_get('apachesolr_facet_query_initial_limit_default', 10);
 
+        // Get the path to this node for appending a new query
+        $path_base = substr($_GET['q'], 0, strrpos($_GET['q'], '/')) . '/';
+
         // Handle taxonomy vocabulary facets
         if ((strpos($delta, 'im_vid_') === 0) && module_exists('taxonomy')) {
 
@@ -366,13 +369,13 @@
               if ($active = $query->has_field('tid', $tid)) {
                 $contains_active = TRUE;
                 $new_query->remove_field('tid', $term->tid);
-                $path = 'search/' . arg(1) . '/' . $new_query->get_query_basic();
+                $path = $path_base . $new_query->get_query_basic();
                 $querystring = $new_query->get_url_querystring();
                 $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
               }
               else {
                 $new_query->add_field('tid', $term->tid);
-                $path = 'search/' . arg(1) . '/' . $new_query->get_query_basic();
+                $path = $path_base . $new_query->get_query_basic();
                 $querystring = $new_query->get_url_querystring();
               }
               $countsort = $count == 0 ? '' : 1 / $count;
@@ -402,7 +405,7 @@
           case 'currentsearch':
             $fields = $query->get_fields();
             $search_keys = $query->get_query_basic();
-            $path = 'search/' . arg(1) . '/' . $search_keys;
+            $path = $path_base . $search_keys;
             $options = array();
             if (!$fields) {
               $options['attributes']['class'] = 'active';
@@ -412,7 +415,7 @@
               if ($field['#name']) {
                 $new_query = clone $query;
                 $new_query->remove_field($field['#name'], $field['#value']);
-                $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
+                $path = $path_base . $new_query->get_query_basic();
                 $querystring = $new_query->get_url_querystring();
                 $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
                 if (! $fielddisplay = theme("apachesolr_breadcrumb_". $field['#name'], $field['#value'])) {
@@ -500,12 +503,15 @@
       }
       $new_keywords = strtr($query->get_query_basic(), $replacements);
 
+      // Get the path to this node for appending a new query
+      $path_base = substr($_GET['q'], 0, strrpos($_GET['q'], '/')) . '/';
+
       $form['basic']['suggestion'] = array(
         '#prefix' => '<div class="spelling-suggestions">',
         '#suffix' => '</div>',
         '#type' => 'item',
         '#title' => t('Did you mean'),
-        '#value' => l($new_keywords, 'search/'. arg(1) .'/'. $new_keywords),
+        '#value' => l($new_keywords, $path_base . $new_keywords),
       );
     }
   }
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.107
diff -u -r1.1.2.12.2.107 apachesolr.module
--- apachesolr.module	10 Feb 2009 20:47:03 -0000	1.1.2.12.2.107
+++ apachesolr.module	23 Feb 2009 14:08:58 -0000
@@ -618,7 +618,11 @@
             }
 
             $sort_links = array();
-            $path = 'search/' . arg(1) . '/' . $query->get_query_basic();
+
+            // Get the path to this node for appending a new query
+            $path_base = substr($_GET['q'], 0, strrpos($_GET['q'], '/')) . '/';
+            
+            $path = $path_base . $query->get_query_basic();
             $new_query = clone $query;
             foreach ($sorts as $type => $sort) {
               $new_sort = isset($solrsorts[$type]) ? $solrsorts[$type] == 'asc' ? 'desc' : 'asc' : $sort['default'];
@@ -645,6 +649,10 @@
   if (!empty($response->facet_counts->facet_fields->$facet_field)) {
     $contains_active = FALSE;
     $items = array();
+
+    // Get the path to this page for appending a new query
+    $path_base = substr($_GET['q'], 0, strrpos($_GET['q'], '/')) . '/';
+
     foreach ($response->facet_counts->facet_fields->$facet_field as $facet => $count) {
       // Solr sends this back if it's empty.
       if ($facet == '_empty_') {
@@ -662,14 +670,13 @@
       if ($active = $query->has_field($facet_field, $facet)) {
         $contains_active = TRUE;
         $new_query->remove_field($facet_field, $facet);
-        // TODO: don't assume 'search' - find the real path.
-        $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
+        $path = $path_base . $new_query->get_query_basic();
         $querystring = $new_query->get_url_querystring();
         $unclick_link = theme('apachesolr_unclick_link', $path, $querystring);
       }
       else {
         $new_query->add_field($facet_field, $facet);
-        $path = 'search/'. arg(1) .'/'. $new_query->get_query_basic();
+        $path = $path_base . $new_query->get_query_basic();
         $querystring = $new_query->get_url_querystring();
       }
       $countsort = $count == 0 ? '' : 1 / $count;
