Hi.
Just return the appropriate header if you are routing them OnPageNotFound. You obviously don’t want to send the 404 Not Found header if you are finding it for them. The standard 302 Found should be what you are wanting, or possibly just a simple 200 OK.
In my original code I just did a MODX->sendForward command, not a 404, 302 or 200 redirect.
I am not sure how to do the above.
Anyway, I did the following hack, I know you’re not meant to hack the core but I really had no other choice:
Edited the document.parser.class.inc.php and added the lines at 1128:
// Find position of first occurrence of `offer` in the requested URL
$RequestURL = $this->documentIdentifier;
$pos = strpos($RequestURL, "offer/" );
if ($pos <> 0)
{
$url = str_replace("http://", "", $RequestURL);
$split_url = explode('/', $url);
if ($debug == true)
{
print "<br />URL SPLIT: " . print_r($split_url);
} // end if
// Build URL of page without the offer code
if ( (is_array($split_url)) && (sizeof($split_url)>0) )
{
if (!$this->is_str_empty($split_url[0]))
{
$this->documentIdentifier = $split_url[0];
}
if (!$this->is_str_empty($split_url[1]))
{
$this->documentIdentifier .= '/' . $split_url[1];
}
} // end if
} // end if
Basically I find the occurrence of /latest-offers/offer/ and consider it as being a request for latest-offers/offer/ page, then the offer page itself does all the handling, including any 404 redirection.
Although, a 302/200 redirection could possibly work in a plug-in but I am concerned that it will still be considered a 404 because the page doesn’t really exist, and is all handled inside the offer page.
Anyway, this hack is working for the moment; if it doesn’t do the job then I will change it to a 302/200 redirection.
Any notes on how to accomplish a 302/200 redirection in a plugin working on "OnPageNotFound" please let me know.
Thanks.