diff --git a/includes/service.inc b/includes/service.inc
index b2a1e7c..e134a07 100644
--- a/includes/service.inc
+++ b/includes/service.inc
@@ -84,11 +84,10 @@ class SearchApiSolrService extends SearchApiAbstractService {
   public function configurationForm(array $form, array &$form_state) {
     if ($this->options) {
       // Editing this server
-      $url = 'http://' . $this->options['host'] . ':' . $this->options['port'] . $this->options['path'];
       $form['server_description'] = array(
         '#type' => 'item',
         '#title' => t('Solr server URI'),
-        '#description' => l($url, $url),
+        '#description' => $this->getServerLink(),
       );
     }
 
@@ -263,11 +262,10 @@ class SearchApiSolrService extends SearchApiAbstractService {
     $output = '';
     $options = $this->options;
 
-    $url = 'http://' . $options['host'] . ':' . $options['port'] . $options['path'];
     $output .= "<dl>\n  <dt>";
     $output .= t('Solr server URI');
     $output .= "</dt>\n  <dd>";
-    $output .= l($url, $url);
+    $output .= $this->getServerLink();
     $output .= '</dd>';
     if ($options['http_user']) {
       $output .= "\n  <dt>";
@@ -284,6 +282,21 @@ class SearchApiSolrService extends SearchApiAbstractService {
   }
 
   /**
+   * Returns a link to the Solr server, if the necessary options are set.
+   */
+  public function getServerLink() {
+    if (!$this->options) {
+      return '';
+    }
+    $host = $this->options['host'];
+    if ($host == 'localhost' && !empty($_SERVER['SERVER_NAME'])) {
+      $host = $_SERVER['SERVER_NAME'];
+    }
+    $url = 'http://' . $host . ':' . $this->options['port'] . $this->options['path'];
+    return l($url, $url);
+  }
+
+  /**
    * Create a connection to the Solr server as configured in $this->options.
    */
   protected function connect() {
