diff --git a/modules/aggregator.module b/modules/aggregator.module
index da6b17fe779f3462a815a2e778c6c3bb113b01c3..7463012ebb66a29e8676f7ed57098b7fcc123f27 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -1162,8 +1162,6 @@ function aggregator_page_sources() {
  * Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
  */
 function aggregator_page_rss() {
-  global $base_url;
-
   // arg(2) is the passed cid, only select for that category
   $result = NULL;
   if (arg(2)) {
@@ -1197,7 +1195,7 @@ function aggregator_page_rss() {
 
   $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   $output .= "<rss version=\"2.0\">\n";
-  $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), $base_url . '/' . url('aggregator' . $url), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en');
+  $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), url('aggregator' . $url, NULL, NULL, TRUE), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en');
   $output .= "</rss>\n";
 
   drupal_set_header('Content-Type: text/xml; charset=utf-8');
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index da6b17fe779f3462a815a2e778c6c3bb113b01c3..7463012ebb66a29e8676f7ed57098b7fcc123f27 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -1162,8 +1162,6 @@ function aggregator_page_sources() {
  * Menu callback; generate an RSS 0.92 feed of aggregator items or categories.
  */
 function aggregator_page_rss() {
-  global $base_url;
-
   // arg(2) is the passed cid, only select for that category
   $result = NULL;
   if (arg(2)) {
@@ -1197,7 +1195,7 @@ function aggregator_page_rss() {
 
   $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   $output .= "<rss version=\"2.0\">\n";
-  $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), $base_url . '/' . url('aggregator' . $url), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en');
+  $output .= format_rss_channel(variable_get('site_name', t('Drupal')) . ' ' . t('aggregator'), url('aggregator' . $url, NULL, NULL, TRUE), variable_get('site_name', t('Drupal')) . ' - ' . t('aggregated feeds') . $title, $items, 'en');
   $output .= "</rss>\n";
 
   drupal_set_header('Content-Type: text/xml; charset=utf-8');