PHP code example of mattmezza / shrtnr
1. Go to this page and download the library: Download mattmezza/shrtnr library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mattmezza / shrtnr example snippets
$both = explode("?", $_SERVER["REQUEST_URI"]);
$uri = $both[0];
$shrtnr = new Shrtnr();
try {
$to = $shrtnr->shrtn($uri);
if (count($both) > 1) {
$to .= "?" . $_SERVER["QUERY_STRING"];
}
header("Location: $to");
} catch (NoRuleException $e) {
die($e->getMessage());
}