diff --git a/config/schema/uptime_widget.schema.yml b/config/schema/uptime_widget.schema.yml
index 1b01158..5c62f1a 100644
--- a/config/schema/uptime_widget.schema.yml
+++ b/config/schema/uptime_widget.schema.yml
@@ -20,6 +20,8 @@ uptime_widget.settings:
       type: boolean
     notice_enabled:
       type: boolean
+    url_name:
+      type: string
     year:
       type: string
     prepend:
diff --git a/src/Form/UptimeAdminSettingsForm.php b/src/Form/UptimeAdminSettingsForm.php
index 84b735c..c535450 100644
--- a/src/Form/UptimeAdminSettingsForm.php
+++ b/src/Form/UptimeAdminSettingsForm.php
@@ -10,6 +10,7 @@ use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Link;
 use Drupal\uptime_widget\Service\UptimeWidgetService;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
  * {@inheritdoc}
@@ -31,17 +32,34 @@ class UptimeAdminSettingsForm extends ConfigFormBase {
   protected $state;
 
   /**
+   * The currently active request object.
+   *
+   * @var \Symfony\Component\HttpFoundation\Request
+   */
+  protected $request;
+
+  /**
    * Constructs a new UptimeAdminSettingsForm.
    *
    * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
    *   The factory for configuration objects.
+   * @param \Drupal\uptime_widget\Service\UptimeWidgetService $uptime_widget_service
+   *   The uptime_widget service object.
    * @param \Drupal\Core\State\StateInterface $state
    *   The state service.
+   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
+   *   The currently active request object.
    */
-  public function __construct(ConfigFactoryInterface $config_factory, UptimeWidgetService $uptime_widget_service, StateInterface $state) {
+  public function __construct(
+    ConfigFactoryInterface $config_factory,
+    UptimeWidgetService $uptime_widget_service,
+    StateInterface $state,
+    RequestStack $request_stack
+  ) {
     parent::__construct($config_factory);
     $this->uptimeWidgetService = $uptime_widget_service;
     $this->state = $state;
+    $this->request = $request_stack->getCurrentRequest();
   }
 
   /**
@@ -51,7 +69,8 @@ class UptimeAdminSettingsForm extends ConfigFormBase {
     return new static(
       $container->get('config.factory'),
       $container->get('uptime_widget'),
-      $container->get('state')
+      $container->get('state'),
+      $container->get('request_stack')
     );
   }
 
@@ -224,14 +243,17 @@ class UptimeAdminSettingsForm extends ConfigFormBase {
       '#default_value' => $config->get('notice_enabled'),
     ];
 
+    // Set the default option as stored.
+    $default = $config->get('url_name');
+    if (!isset($default) || empty($default)) {
+      $config->set('url_name', $this->request->getHost())->save();
+    }
     // For the examples we use real data.
     // Current domain name without the leading protocol.
-    $host = $config->get('url_name');
-    if (!isset($host) || empty($host)) {
-      $config->set('url_name', parse_url($GLOBALS['base_url'], PHP_URL_HOST))->save();
-    }
-    if ($host != parse_url($GLOBALS['base_url'], PHP_URL_HOST)) {
-      $host = parse_url($GLOBALS['base_url'], PHP_URL_HOST);
+    $host = $this->request->getHost();
+    // Force $default to be a valid option if not equal to one of the three.
+    if ($default != $host && $default != $this->config('system.site')->get('name') && $default != ' ') {
+      $default = $host;
     }
     $year = $config->get('year');
     $notice = $config->get('prepend') . ' ©' . (($year != date('Y') && !empty($year)) ? $year . '-' . date('Y') : date('Y'));
@@ -244,7 +266,7 @@ class UptimeAdminSettingsForm extends ConfigFormBase {
         $this->config('system.site')->get('name') => '<strong>' . $notice . ' ' . $this->config('system.site')->get('name') . '</strong> ' . $this->t("(Site name. Preferable if the site name is a person's full name or a company name.)"),
         ' ' => '<strong>' . $notice . '</strong> ' . $this->t('(Leaving out the designation of owner is not recommended.)'),
       ],
-      '#default_value' => $host,
+      '#default_value' => $default,
       '#description' => $this->t("'Year of first publication' is not used until entered below, for example © 2009-") . date('Y') . '. ' . t('Save this form to refresh above examples.'),
     ];
 
