Skip to content

Instantly share code, notes, and snippets.

@vindia
Created February 28, 2012 11:50
Show Gist options
  • Save vindia/1932097 to your computer and use it in GitHub Desktop.
Save vindia/1932097 to your computer and use it in GitHub Desktop.
Uncached Redirect
<!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>
<?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