Shorten your URL

Based on a tutorialzine.com article, I wrote an own URL shortener. Put everything in directory /s

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /s/index.php?$1 [last]

index.php

$links = parse_ini_file('links.ini');
$l=filter_var( $_SERVER['REQUEST_URI'], FILTER_SANITIZE_STRING);
$l=preg_replace ('/\/s\//','',$l);
if($l!='' && array_key_exists($l, $links)){
  header('Location: ' . $links[$l]);
}
elseif (substr($l,0,4)=="http") {
  $sl = sprintf( '%04x%04X', mt_rand( 0, 0xffff ), mt_rand( 0,, 0xffff) );
  echo $_SERVER[HTTP_HOST]  . '/s/' . $sl;
  $out = $sl.' = '.$l;
  file_put_contents('links.ini', $out."\n", FILE_APPEND);
}

links.ini

Gel = "https://www.google.com/"

Bookmarklet ShortenURL

javascript: document.location = 'https://www.www.wjst.de/s/' + document.location.href