Skip to content

Instantly share code, notes, and snippets.

@Shaz3e
Last active November 26, 2015 15:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shaz3e/82bc445330f7d7a2c7b5 to your computer and use it in GitHub Desktop.
Save Shaz3e/82bc445330f7d7a2c7b5 to your computer and use it in GitHub Desktop.
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?l=$1 [L]

Create a Simple URL Shortener With 10 Lines of PHP

Orginally Posted at tutorialzine

<?php
$links = parse_ini_file('links.ini');
if(isset($_GET['l']) && array_key_exists($_GET['l'], $links)){
header('Location: ' . $links[$_GET['l']]);
}else{
header('HTTP/1.0 404 Not Found');
echo 'Unknown link.';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment