Exemple #1
0
<?php

Typeframe::CurrentPage()->registerCallback(Typeframe::CurrentPage()->controllerPath(), function () {
    if (http_response_code() == 404) {
        $redirects = new Model_Redirect();
        $redirects->where('original = ? OR original = ? OR original = ?', Typeframe::CurrentPage()->uri(), Typeframe::CurrentPage()->uri() . '/', '~' . substr(Typeframe::CurrentPage()->uri(), strlen(TYPEF_WEB_DIR)));
        $redirect = $redirects->getFirst();
        if ($redirect->exists()) {
            Typeframe::Redirect('Redirecting to ' . $redirect['destination'] . '...', $redirect['destination'], 0, true, 301);
        }
    }
});