Chủ Nhật, 23 tháng 2, 2014

Joomla ERROR PAGE - Redirect to URL

File hiệu chỉnh: Hiệu chỉnh file templates/yourtemplate/error.php
Nguyên tắc hoạt động: khi jooml báo lỗi link sẽ chạy file error.php, lúc này file sẽ trỏ đến 1 bài viết trong joomla.
Mục đích: để giữ template hiển thị và style.
So sánh: có lợi hơn rất là là nhiều nếu redirect bằng html header <meta http-equiv="refresh" content="0; url=http://example.com/" />, lý do khi gặp file php là đang chạy ở server và redirect. Còn nếu chạy HTML Redirect thì lúc về đến client rồi mới redirect - lúc này người dùng sẽ thấy được trang trắng khoảng 1s.
Source:
<?php
$location=$this->baseurl.'/index.php?option=com_content&view=article&id=126&Itemid=718';
header("Location:".$location); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

0 nhận xét:

Đăng nhận xét