Return to Snippet

Revision: 6807
at June 16, 2008 11:39 by tomdebruin


Initial Code
<?php $mysite = "http://www.theUrlOfYourSite.com"; ?>
<a href="<?php $url = parse_url($_SERVER['HTTP_REFERER']); /* detect referrer */ 
if ($url['host'] == $_SERVER['HTTP_HOST']) { /* if domain matches, go back */
echo $_SERVER['HTTP_REFERER']; } else { echo $mysite; } ?>"><!-- if from another domain, send them to my index page -->Back a page</a>

Initial URL

                                

Initial Description
A back button that detects if the visitor came from your site initially. If they came from another URL it sends them to your index page instead.

Initial Title
Intelligent Back Button.

Initial Tags

                                

Initial Language
PHP