PHP Redirect to Page Class: Generate URLs to redirect to destination pages

Recommend this page to a friend!
  Info   View files Example   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 152 All time: 8,827 This week: 237Up
Version License PHP version Categories
php-redirect-class 1.0GNU General Publi...5HTTP, PHP 5, Security
Description Author

This package can generate URLs to redirect to destination pages.

It can take a given destination URL and generates a link URL for the current site.

When a user clicks on a link with the generated URL, the browser will be redirected to the destination URL.

The generated link contains a verification code that is generated by creating an hash value based the destination URL and a secret salt value.

The class also verifies if the page with the destination URL exists before it redirects the user browser to the destination URL.

Picture of Jason Olson
  Performance   Level  
Name: Jason Olson is available for providing paid consulting. Contact Jason Olson .
Classes: 4 packages by
Country: United States United States
Age: ???
All time rank: 3523434 in United States United States
Week rank: 261 Up25 in United States United States Up
Innovation award
Innovation award
Nominee: 1x

Details

php-redirect

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

When Google is evaluating inbound and outbound links, using a tool like this will obfuscate the redirect chain, because this URL will be seen as the destination of your internal links. This may or may not be your intended action. If you really want the external links to really know what page sent them along to them, you'll want to use another method such as Javascript. However, in other cases, you might not want to directly reveal the source for the redirect. For example, lets say you run a web based email application, and you don't want the external links to see the referral source of the user's webmail URL.

Configuration

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

Security

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.

License

GNU General Public License v3.0 (GNU GPLv3) http://www.gnu.org/licenses/gpl-3.0-standalone.html

  Files folder image Files  
File Role Description
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation
Plain text file redirect.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:152
This week:0
All time:8,827
This week:237Up

For more information send a message to info at phpclasses dot org.