diff --git a/shurly.install b/shurly.install
index 0ccae87..1a2eeb9 100644
--- a/shurly.install
+++ b/shurly.install
@@ -180,4 +180,5 @@ function shurly_uninstall() {
   variable_del('shurly_length');
   variable_del('shurly_counter');
   variable_del('shurly_index');
+  variable_del('shurly_base');
 }
diff --git a/shurly.module b/shurly.module
index 1f721e1..aefc523 100644
--- a/shurly.module
+++ b/shurly.module
@@ -174,6 +174,8 @@ function shurly_confirm_delete_form_submit($form, &$form_state) {
  * The main form to create new short URLs.
  */
 function shurly_create_form($form_state) {
+  global $base_url;
+
   $form['long_url'] = array(
     '#title' => t('Enter a long URL to make short'),
     '#type' => 'textfield',
@@ -187,7 +189,7 @@ function shurly_create_form($form_state) {
   $form['short_url'] = array(
     '#type' => 'textfield',
     '#size' => 6,
-    '#field_prefix' => $GLOBALS['base_url'] .'/',
+    '#field_prefix' => variable_get('shurly_base', $base_url) . '/',
     '#field_suffix' => ' <span class="shurly-choose">&lt;--- ' . t('create custom URL') . '</span>',
     '#default_value' => $short_default,
     '#access' => user_access('Enter custom URLs'),
@@ -292,10 +294,12 @@ function shurly_create_form_validate(&$form, &$form_state) {
 }
 
 function shurly_create_form_submit($form, &$form_state) {
+  global $base_url;
+
   // submit the short URL form
   $long_url = $form_state['storage']['shurly']['long_url'] = $form_state['values']['long_url'];
   $short_url = $form_state['storage']['shurly']['short_url'] = $form_state['values']['short_url'];
-  $final_url = $form_state['storage']['shurly']['final_url'] = rawurldecode(_surl($short_url, array('absolute' => TRUE)));
+  $final_url = $form_state['storage']['shurly']['final_url'] = rawurldecode(_surl($short_url, array('absolute' => TRUE, 'base_url' => variable_get('shurly_base', $base_url))));
   $custom = $form_state['custom'];
   if (empty($form_state['url_exists'])) {
     shurly_save_url($long_url, $short_url, NULL, $custom);
@@ -304,6 +308,22 @@ function shurly_create_form_submit($form, &$form_state) {
 
 
 function shurly_settings_form($form_state) {
+  global $base_url;
+
+  $form['shurly_url'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Base URL'),
+    '#tree' => TRUE,
+    '#description' => t('If you want to use a dedicated url for the short URL\'s, enter below that short base URL to be used.'),
+  );
+
+  $form['shurly_url']['shurly_base'] = array(
+    '#type' => 'textfield',
+    '#description' => t('Default is the base URL of the Drupal installation.'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('shurly_base', $base_url),
+  );
+
   $form['shurly_throttle'] = array(
     '#type' => 'fieldset',
     '#title' => t('Rate limiting'),
@@ -343,6 +363,13 @@ function shurly_settings_form($form_state) {
   return system_settings_form($form);
 }
 
+function shurly_settings_form_validate($form, $form_state){
+  $custom_base_url = $form_state['values']['shurly_url']['shurly_base'];
+  if(!valid_url($custom_base_url, TRUE)){
+    form_set_error('settings_shurly_base', t('The base URL is not valid.'));
+    }
+}
+
 /**
  * From http://www.php.net/manual/en/function.base-convert.php#52450
  *
@@ -425,6 +452,7 @@ function shurly_flood_is_allowed($name, $threshold, $window = 3600, $identifier
  *   'short_url' => the short url
  */
 function shurly_shorten($long_url, $custom = NULL, $account = NULL) {
+  global $base_url;
   $success = FALSE;
   $account = ($account) ? $account : $GLOBALS['user'];
   $error = '';
@@ -470,7 +498,7 @@ function shurly_shorten($long_url, $custom = NULL, $account = NULL) {
     'success' => $success,
     'error' => $error,
     'longUrl' => $long_url,
-    'shortUrl' => isset($short) ? _surl($short, array('absolute' => TRUE)) : '',
+    'shortUrl' => isset($short) ? _surl($short, array('absolute' => TRUE, 'base_url' => variable_get('shurly_base', $base_url))) : '',
     'user' => (int)$account->uid,
   );
 }
