PHP Classes
elePHPant
Icontem

Status 404 PHP Find Best Match Page: Find best match URL when accessing an invalid page

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-05-02 (3 months ago) RSS 2.0 feedStarStarStar 46%Total: 467 All time: 5,825 This week: 617Up
Version License PHP version Categories
status-404-find-best 1.0.0GNU General Publi...5.0HTTP, PHP 5, Text processing, Artific...
Description Author

This class can find best match URL when accessing an invalid page.

It takes the list of URIs of valid pages and finds the page that matches better the URI of the current request when it is not valid.

The class redirects the browser to the best match page URL.

Innovation Award
PHP Programming Innovation award nominee
September 2013
Number 5


Prize: One copy of the Zend Studio
Some times users access inexistent pages because they mistyped the URL. In that case it would be better to try to fix the URL for the user instead of just say it is wrong.

This class can attempt to fix incorrect URLs using a list of URLs that are known to be correct.

Manuel Lemos
  Performance   Level  
Name: Peter Kahl <contact>
Classes: 30 packages by
Country: Hong Kong Hong Kong
Age: ???
All time rank: 7064 in Hong Kong Hong Kong
Week rank: 21 Up1 in Hong Kong Hong Kong Up
Innovation award
Innovation award
Nominee: 17x

Details

Not Found Alternative

(formerly 'Status 404 Find Best Match Page')

When requested page URI is not found in the list of available pages, closest matching page URI will be found and a redirect header will be returned.

This package will please all those concerned with search engine optimisation (SEO), and in situations where URIs often change; it eliminates the need for URL rewrites.

Usage

use peterkahl\NotFoundAlternative\NotFoundAlternative;

# For testing purposes, we set these; otherwise to be omitted.
$_SERVER['REQUEST_URI']     = '/contatcus?lang=en-us';
$_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1';
$_SERVER['HTTP_SCHEME']     = 'https';
$_SERVER['HTTP_HOST']       = 'www.blah.sample';
# ---- End of testing variables ----

$notfoundObj = new NotFoundAlternative;
$notfoundObj->AvailableURI = array(
  '/',
  '/about',
  '/products',
  '/services',
  '/contact-us',
  '/news',
);
$notfoundObj->CheckURI();
# The script serves Status 301 permanent redirect header
# and Location header 'https://www.blah.sample/contact-us?lang=en-us'
# and then exits.

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file LICENSE Lic. License
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file NotFoundAlternative.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:467
This week:0
All time:5,825
This week:617Up
User Ratings User Comments (1)
 All time
Utility:66%StarStarStarStar
Consistency:66%StarStarStarStar
Documentation:66%StarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:46%StarStarStar
Rank:2507
 
good
3 years ago (Rahul Shambharkar)
80%StarStarStarStarStar