Created
February 28, 2012 11:50
-
-
Save vindia/1932097 to your computer and use it in GitHub Desktop.
Uncached Redirect
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 characters
<!DOCTYPE html> | |
<title>Anti spam test</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){ | |
$('a').click(function(e){ | |
e.preventDefault(); | |
location.href = $(this).attr('rel') ; | |
}); | |
}); | |
</script> | |
<!-- Non javascript enabled browsers will follow the href, all others will be send through the redirect script --> | |
<!-- This means that all non-JS users are not tracked --> | |
<a href="http://disney.com" rel="redirect.php?url=http://disney.com">Click here</a> |
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 characters
<?php | |
# Logging | |
date_default_timezone_set('Europe/Amsterdam'); | |
file_put_contents('redirect.log', sprintf("%s\t%s\n", date('Y-m-d H:i:s'), $_GET['url']), FILE_APPEND); | |
# Actual redirect | |
# Expires header is not needed, as must-revalidate already implies this | |
header('Cache-Control: no-store, no-cache, must-revalidate'); | |
header('Location: ' . $_GET['url'], true, 301); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment