Skip to content

Instantly share code, notes, and snippets.

@ofyalcin
Created June 24, 2017 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ofyalcin/0c42bc2379665ffc3b99a707d19a5306 to your computer and use it in GitHub Desktop.
Save ofyalcin/0c42bc2379665ffc3b99a707d19a5306 to your computer and use it in GitHub Desktop.
/tavsiye/index.php (detaylı anlatım: https://blogkurdu.net/wordpress-referans-link-yonlendirme/)
<?php
$id = isset( $_GET['id'] ) ? rtrim( trim( $_GET['id'] ), '/' ) : 'default';
$f = fopen( 'redirects.txt', 'r' );
$urls = array();
if ( !$f ) {
echo 'Yönlendirmeler için bir txt dosyası oluşturduğunuzdan emin olun.';
die;
}
while( $data = fgetcsv( $f ) ) {
if ( !isset( $data[0] ) || !isset( $data[1] ) )
continue;
$key = trim( $data[0] );
$val = trim( $data[1] );
$urls[ $key ] = $val;
}
$url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : false );
if ( $url ) {
header( "X-Robots-Tag: noindex, nofollow", true );
header( "Location: " . $url, 302 );
die;
} else {
echo '<p>default olarak bir link eklediğinizden emin olun. Örneğin:</p>
<pre>default,https://blogkurdu.net</pre>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment