PHP code example of truecastdesign / jsonredirects

1. Go to this page and download the library: Download truecastdesign/jsonredirects 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/ */

    

truecastdesign / jsonredirects example snippets


Truecast\Redirects::redirect(['request'=>$_SERVER['REQUEST_URI'], 'lookup'=>BP.'/redirects.json', 'type'=>'301']);

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$Redirects->add($App->request->post->fromUrl, $App->request->post->toUrl);

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$Redirects->remove($App->request->delete->fromUrl);

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$list = $Redirects->getRedirectsList();

// array ['from-url'=>'to-url', 'from-url'=>'to-url']

$Redirects = new App\Redirects(BP.'/config/redirects.json');
$cleanedURL = $Redirects->cleanUrl($url);