DownloadPage not found? Serve an alternative!
When requested page URI is not found in the list of available pages, a 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.
|