I created a plugin folder in the path wp-content/plugins/hijack and then stuck this file plugin.php inside.
<?php
/*
Plugin Name: Hijack
Plugin URI: http://example.com/contact
Description: Sample URL Hijacker Plugin
Author: John Doe
Version: 1.1
Author URI: http://example.com/contact
*/
add_filter('init','Hijack');
function Hijack() {
$URL = get_bloginfo('wpurl');
$PLUGIN = $_SERVER['SCRIPT_FILENAME'];
$PLUGIN = str_replace('/index.php','',$PLUGIN);
$PLUGIN = $PLUGIN . '/wp-content/plugins/hijack';
$sHijack = '/catalog';
$sURL = $_SERVER['REDIRECT_URL'];
if (strpos(' ' . $sURL,$sHijack)>0) {
$sYank = $URL;
$sYank = str_replace('http://','',$sYank);
$sYank = str_replace('https://','',$sYank);
$sYank = str_replace($_SERVER['SERVER_NAME'] . '/','',$sYank);
$sYank = $sYank . $sHijack;
$sTemp = str_replace($sYank,'',$sURL);
$sTemp = str_replace($sYank . '/','',$sTemp);
$sTemp = str_replace('//','/',$sTemp);
if ((substr($sTemp,-1,1) == '/') and ($sTemp != '/')) {
$sTemp = substr($sTemp, 0, -1);
}
define('VARS',$sTemp);
include($PLUGIN . '/index.php');
exit(0);
}
}
Then, from there, I added wp-content/plugins/hijack/index.php as just a test case and used this code:
<?php
echo VARS;
echo "<br />\n";
print_r($_GET);
At that point, when the plugin was activated, I could redirect all URLs like /catalog, /catalog/products/400, etc. to the index.php file in my hijack plugin folder, and then index.php would act like a front controller for my web app loaded inside of WordPress. (I hope you are familiar with the MVC model of PHP programming.) The front controller could then be rewritten to call page controllers based on what was in VARS.