Last active
January 7, 2025 07:26
-
Star
(106)
You must be signed in to star a gist -
Fork
(29)
You must be signed in to fork a gist
-
-
Save jdevalk/5622742 to your computer and use it in GitHub Desktop.
Revisions
-
Joost de Valk revised this gist
May 22, 2013 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php $id = isset( $_GET['id'] ) ? rtrim( trim( $_GET['id'] ), '/' ) : 'default'; $f = fopen( 'redirects.txt', 'r' ); $urls = array(); // The file didn't open correctly. @@ -12,7 +12,12 @@ // Read the input file and parse it into an array while( $data = fgetcsv( $f ) ) { if ( !isset( $data[0] ) || !isset( $data[1] ) ) continue; $key = trim( $data[0] ); $val = trim( $data[1] ); $urls[ $key ] = $val; } // Check if the given ID is set, if it is, set the URL to that, if not, default -
Joost de Valk revised this gist
May 22, 2013 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,27 @@ <?php $id = isset( $_GET['id'] ) ? rtrim( trim( $_GET['id'] ), '/' ) : 'default'; $f = fopen( 'redirects.txt', 'r' ); $urls = array(); // The file didn't open correctly. if ( !$f ) { echo 'Make sure you create your redirects.txt file and that it\'s readable by the redirect script.'; die; } // Read the input file and parse it into an array while( $data = fgetcsv( $f ) ) { $urls[ $data[0] ] = $data[1]; } // Check if the given ID is set, if it is, set the URL to that, if not, default $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>Make sure yor redirects.txt file contains a default value, syntax:</p> <pre>default,http://example.com</pre> -
Joost de Valk revised this gist
May 22, 2013 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <?php $id = isset( $_GET['id'] ) ? $_GET['id'] : 'default'; $f = fopen( 'redirects.txt', 'r' ); $urls = array(); @@ -21,5 +21,9 @@ header( "X-Robots-Tag: noindex, nofollow", true ); if ( !empty( $url ) ) { header( "Location: " . $url, 302 ); die; } else { echo '<p>Make sure yor redirects.txt file contains a default value, syntax:</p> <pre>default,http://example.com</pre> <p>Where you should replace example.com with your domain.</p>'; } -
Joost de Valk revised this gist
May 22, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,8 @@ // Check if the given ID is set, if it is, set the URL to that, if not, default $url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : '' ); header( "X-Robots-Tag: noindex, nofollow", true ); if ( !empty( $url ) ) { header( "Location: " . $url, 302 ); die; } -
Joost de Valk revised this gist
May 22, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ // Check if the given ID is set, if it is, set the URL to that, if not, default $url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : '' ); if ( !empty( $url ) ) { header( "X-Robots-Tag: noindex, nofollow", true ); header( "Location: " . $url, 302 ); die; -
Joost de Valk revised this gist
May 21, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <?php $id = isset( $_GET['id'] ) ? $_GET['id'] : 'default'; $f = fopen( 'redirects.txt', 'r' ); $urls = array(); // The file didn't open correctly. -
Joost de Valk created this gist
May 21, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^index\.php$ - [L] RewriteRule (.*) ./index.php?id=$1 [L] </IfModule> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ <?php $id = isset( $_GET['id'] ) ? $_GET['id'] : 'default'; $f = fopen( 'redirects.txt', 'r' ); $urls = array(); // The file didn't open correctly. if ( !$f ) { echo 'Make sure you create your redirects.txt file and that it\'s readable by the redirect script.'; die; } // Read the input file and parse it into an array while( $data = fgetcsv( $f ) ) { $urls[ $data[0] ] = $data[1]; } // Check if the given ID is set, if it is, set the URL to that, if not, default $url = ( isset( $urls[ $id ] ) ) ? $urls[ $id ] : ( isset( $urls[ 'default' ] ) ? $urls[ 'default' ] : '' ); if ( isset( $url ) ) { header( "X-Robots-Tag: noindex, nofollow", true ); header( "Location: " . $url, 302 ); die; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ default,http://example.com yoast,http://yoast.com test,http://yoast.com/?p=2