diff --git a/path_redirect_import.services.yml b/path_redirect_import.services.yml
index a137c31..cbbf0a9 100644
--- a/path_redirect_import.services.yml
+++ b/path_redirect_import.services.yml
@@ -1,4 +1,4 @@
 services:
   path_redirect_import.importer:
     class: Drupal\path_redirect_import\ImporterService
-    arguments: []
+    arguments: ['@database']
diff --git a/src/Form/RedirectImportForm.php b/src/Form/RedirectImportForm.php
index f327442..c035bfc 100644
--- a/src/Form/RedirectImportForm.php
+++ b/src/Form/RedirectImportForm.php
@@ -44,6 +44,19 @@ class RedirectImportForm extends FormBase {
       '#size' => 4,
       '#default_value' => ',',
     ];
+
+    $form['csv']['clean_database'] = [
+      '#type' => 'checkbox',
+      '#title' => $this->t('Apply redirects to hard coded links in the db?'),
+      '#description' => $this->t('This will go through all database link, text and long text fields to apply the redirects to hard coded links. NOTE: YOU MAY NEED TO CLEAR CACHES FOR EFFECTS TO DISPLAY'),
+    ];
+
+    $form['csv']['clean_database_only'] = [
+      '#type' => 'checkbox',
+      '#title' => $this->t('Do not import redirects, clean database only.'),
+      '#description' => $this->t('If "Apply redirects to hard coded links in the db?" is checked, this option will only perform the database clean operation and not add redirects in drupal.'),
+    ];
+
     $form['csv']['no_headers'] = [
       '#type' => 'checkbox',
       '#title' => $this->t('No headers'),
@@ -138,12 +151,21 @@ class RedirectImportForm extends FormBase {
       'delimiter' => $form_state->getValue('delimiter'),
       'language' => $form_state->getValue('language') ?: Language::LANGCODE_NOT_SPECIFIED,
       'suppress_messages' => $form_state->getValue('suppress_messages'),
+      'clean_database' => $form_state->getValue('clean_database'),
+      'clean_database_only' => $form_state->getValue('clean_database_only'),
     ];
 
     ImporterService::import($this->file, $options);
 
     // Remove file from Drupal managed files & from filesystem.
     file_delete($this->file->id());
+
+    // If db clean clear all caches
+    if ($form_state->getValue('clean_database') == 1) {
+      drupal_flush_all_caches();
+      $renderCache = \Drupal::service('cache.render');
+      $renderCache->invalidateAll();
+    }
   }
 
 }
diff --git a/src/ImporterService.php b/src/ImporterService.php
index 292f50f..5ae3062 100644
--- a/src/ImporterService.php
+++ b/src/ImporterService.php
@@ -14,6 +14,13 @@ use Drupal\Core\Language\Language;
  */
 class ImporterService {
 
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct(Connection $connection) {
+    $this->connection = $connection;
+  }
+
   /**
    * List of status messages to be output in screen.
    *
@@ -49,16 +56,31 @@ class ImporterService {
     else {
       if (PHP_SAPI == 'cli' && function_exists('drush_main')) {
         foreach ($data as $redirect_array) {
-          self::save($redirect_array, $options['override'], []);
+
+          if ($options['clean_database_only'] != 1) {
+            self::save($redirect_array, $options['override'], []);
+          }
+          if ($options['clean_database'] == 1) {
+            self::clean($redirect_array, $options['override'], []);
+          }
+
         }
       }
       else {
         // Save valid redirects.
         foreach ($data as $row) {
-          $operations[] = [
-            ['\Drupal\path_redirect_import\ImporterService', 'save'],
-            [$row, $options['override']],
-          ];
+          if ($options['clean_database_only'] != 1) {
+            $operations[] = [
+              ['\Drupal\path_redirect_import\ImporterService', 'save'],
+              [$row, $options['override']],
+            ];
+          }
+          if ($options['clean_database'] == 1) {
+            $operations[] = [
+              ['\Drupal\path_redirect_import\ImporterService', 'clean'],
+              [$row, $options['override']],
+            ];
+          }
         }
 
         $batch = [
@@ -256,6 +278,149 @@ class ImporterService {
     'status');
   }
 
+  /**
+   * Clean db fields of static links.
+   *
+   * @param str[] $redirect_array
+   *    Keyed array of redirects, in the format
+   *    [source, redirect, status_code, language].
+   * @param bool $override
+   *    A 1 indicates that existing redirects should be updated.
+   */
+  public static function clean($redirect_array, $override) {
+
+    $db = \Drupal::service('database');
+
+    $message_type = 'Cleaned';
+    $parsed_url = UrlHelper::parse(trim($redirect_array['source']));
+    $path = isset($parsed_url['path']) ? $parsed_url['path'] : NULL;
+    $query = isset($parsed_url['query']) ? $parsed_url['query'] : NULL;
+
+    // Currently, the Redirect module's setRedirect function assumes
+    // all paths are internal. If external, we will use redirect_redirect->set.
+    $external_link = FALSE;
+    if (parse_url($redirect_array['redirect'], PHP_URL_SCHEME)) {
+      $external_link = TRUE;
+    }
+
+    // Get all text and textarea fields
+
+    $allFields = array_merge_recursive(
+      \Drupal::service('entity_field.manager')->getFieldMapByFieldType('string'),
+      \Drupal::service('entity_field.manager')->getFieldMapByFieldType('text_long'),
+      \Drupal::service('entity_field.manager')->getFieldMapByFieldType('text_with_summary'),
+      \Drupal::service('entity_field.manager')->getFieldMapByFieldType('link')
+    );
+
+    // Remove whitespaces
+    $redirect_array['source'] = trim($redirect_array['source']);
+
+    $skip_prefixes = FALSE;
+    if (strpos($redirect_array['source'], 'http') === FALSE) {
+      if (strpos($redirect_array['source'], '/') !== 0) {
+        $redirect_array['source'] = '/' . $redirect_array['source'];
+      }
+    }
+    else {
+      $skip_prefixes = TRUE;
+    }
+
+    if (strpos($redirect_array['redirect'], 'http') === FALSE) {
+      if (strpos($redirect_array['redirect'], '/') !== 0) {
+        $redirect_array['redirect'] = '/' . $redirect_array['redirect'];
+      }
+    }
+
+    foreach ($allFields as $entity_name => $entity_fields) {
+      foreach ($entity_fields as $field_name => $field_value) {
+        if (strpos($field_name, 'field_') !== FALSE && $field_name != 'field_name' && $field_name != 'parent_field_name') {
+
+          $host = \Drupal::request()->getHost();
+
+          $suffixes = [
+            '/',
+            ''
+          ];
+
+          foreach ($suffixes as $suffix) {
+
+            if (!$skip_prefixes) {
+              $prefixes = [
+                'http://' . $host,
+                'https://' . $host,
+                $host,
+                '',
+              ];
+            }
+            else {
+              $prefixes = [
+                '',
+              ];
+            }
+
+
+            foreach ($prefixes as $prefix) {
+
+              $source = $redirect_array['source'];
+              $redirect = $redirect_array['redirect'];
+
+              if (substr_compare($redirect, '//', -strlen('//')) === 0) {
+                $redirect = substr($redirect, 0, -1);
+              }
+
+              if ($field_value['type'] == 'link') {
+                $update_sql = '
+  
+                  UPDATE ' . $entity_name . '__' . $field_name . ' SET ' . $field_name . '_uri = REPLACE(' . $field_name . '_uri, :source, :destination) WHERE ' . $field_name . '_uri LIKE :source_where
+  
+                ';
+              }
+              else {
+                $update_sql = '
+  
+                  UPDATE ' . $entity_name . '__' . $field_name . ' SET ' . $field_name . '_value = REPLACE(' . $field_name . '_value, :source, :destination) WHERE INSTR(' . $field_name . '_value, :source) > 0
+  
+                ';
+              }
+
+
+              // Do a search and replace in the database
+              if ($field_value['type'] == 'link') {
+
+                if ($source[0] == '/') {
+                  $prefix = 'internal:';
+                }
+                if ($redirect[0] == '/') {
+                  $redirect = 'internal:' . $redirect;
+                }
+
+                $db->query($update_sql, [
+                  ':source' => $prefix . $source . $suffix,
+                  ':destination' => $redirect,
+                  ':source_where' => '%' . $prefix . $source . $suffix,
+                ]);
+              }
+              else {
+                $db->query($update_sql, [
+                  ':source' => '"' . $prefix . $source . $suffix . '"',
+                  ':destination' => '"' . $redirect . '"',
+                ]);
+              }
+            }
+          }
+        }
+      }
+    }
+
+    drupal_set_message(t('@message_type redirect from @source to @redirect', [
+      '@message_type' => $message_type,
+      '@source' => $redirect_array['source'],
+      '@redirect' => $redirect_array['redirect'],
+    ]),
+      'status');
+
+  }
+
   /**
    * Remove leading slash, if present.
    *
