This class is designed to help you create your own internal redirect link function. This can be used to perform other actions before a user actually leaves your site. This could include logging this action, triggering an alert message, or something else.
Impact on SEO
In the constructor change the following variable:
* $this->secret should be some random, secret padding to secure your page (see security below)
* $this->redirectUrl should be the full url that will call the redirect method
To prevent PageRank hijacking you'll want to make sure that you secure your links with a secret padding. This padding is added to the url to create a MD5 hash to prevent basic PageRank hijacks, which can provide SEO performance perks for the bad guys. Doesn't necessarily negatively affect you (unless it links out to known really bad site), but it can help other businesses who are trying to use your good reputation to help them. Simply set the secret variable to anything you want, it stays hidden from the user and is never exposed, just be sure to change it from the example provided here.
Example Provided - explained - index.php
In the example provided we place two different invocations of the class into a single file for simple demonstration purposes. Here we check to see if the $_GET['url'] was set, and if so, we then call the redirect() method. Otherwise we'll provide a simple link to the phpclasses.org website, showing how the generateRedirect() method works. In a production environment what you'd likely do is have these two control points separated out into different parts of code or file. For example, as part of your VIEW you might use the generateUrl() to create your external links, while the redirects are actually processed by a different URL, for example https://links.domain.com. Additionally, not included here is that instead of simply failing out when no $_GET['url'] is passed, you might display a message to people who are following back a referral URL, so you can explain how visitors were redirected to their site.
GNU General Public License v3.0 (GNU GPLv3)