Chủ Nhật, 3 tháng 9, 2023

Joomla4 error.php check id article redirect


Detail: link url https://domain.php/index.php/1072
Solution: split '/' get last item, is number -> redirect to article

/*CustomRedirect*/
$errUrl= $_SERVER['REQUEST_URI'];    
/*Get Last Number*/
$splitUrls = explode("/", $errUrl);
if(count($splitUrls)>1){
    $lastItem = $splitUrls[count($splitUrls)-1];
    if(is_numeric($lastItem)){
        /*LastIsNumber redirect to article ID*/
        $redirectLink = JUri::base().'?view=article&id='.$lastItem;
        /*echo $redirectLink;*/
        header('Location:'.$redirectLink);
        exit;
    }
}
/*ENDCustom*/


 

0 nhận xét:

Đăng nhận xét