diff --git a/shurly.module b/shurly.module
index 70a013f..1e93c3d 100644
--- a/shurly.module
+++ b/shurly.module
@@ -78,7 +78,7 @@ function shurly_menu() {
 
   $items['admin/config/system/shurly'] = array(
     'title' => 'ShURLy',
-    'description'      => t('Limit the requests of ShURLy links by roles.'),
+    'description'      => t('Configure base url and limit the requests of ShURLy links by roles.'),
     'page callback' => 'drupal_get_form',
     'page arguments' => array('shurly_settings_form'),
     'access arguments' => array('Administer short URLs'),
@@ -251,6 +251,8 @@ function shurly_confirm_delete_form_submit($form, &$form_state) {
  * The main form to create new short URLs.
  */
 function shurly_create_form($form, &$form_state) {
+  global $base_url;
+
   $form['long_url'] = array(
     '#title' => t('Enter a long URL to make short'),
     '#type' => 'textfield',
@@ -264,7 +266,7 @@ function shurly_create_form($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'),
@@ -370,11 +372,12 @@ function shurly_create_form_validate($form, &$form_state) {
  * Submission of the main form
  */
 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'];
 
   $form_state['rebuild'] = TRUE;
@@ -390,6 +393,21 @@ function shurly_create_form_submit($form, &$form_state) {
  * Settings form
  */
 function shurly_settings_form($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',
@@ -435,6 +453,13 @@ function shurly_settings_form($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
  *
@@ -514,6 +539,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 = '';
@@ -559,7 +585,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))) : '',
   );
 }
