Welcome to mirror list, hosted at ThFree Co, Russian Federation.

yourls-go.php - github.com/YOURLS/YOURLS.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 51968dd924cc87d25dd6adb94477c12523cc9adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
define( 'YOURLS_GO', true );
require_once( dirname( __FILE__ ) . '/includes/load-yourls.php' );

// Variables should be defined in yourls-loader.php
if( !isset( $keyword ) ) {
	yourls_do_action( 'redirect_no_keyword' );
	yourls_redirect( YOURLS_SITE, 301 );
}

$keyword = yourls_sanitize_keyword($keyword);

// if we have a page, display and exit
if( yourls_is_page($keyword) ) {
    yourls_page( $keyword );
    return;
}

// if we can get a long URL from the DB, redirect
if( $url = yourls_get_keyword_longurl( $keyword ) ) {
    yourls_redirect_shorturl($url, $keyword);
    return;
}

// Either reserved keyword, or no such keyword
yourls_do_action( 'redirect_keyword_not_found', $keyword );
yourls_redirect( YOURLS_SITE, 302 ); // no 404 to tell browser this might change, and also to not pollute logs
exit();