Home » » Hướng dẫn bỏ ID trên URL của website Joomla 2.5

Hướng dẫn bỏ ID trên URL của website Joomla 2.5

Bạn là webmaster Joomla thì chắc bạn cũng sẽ thấy trong URL có kèm theo ID ví dụ: http://domain.com/category/19-artice, điều này cũng có ảnh hưởng trong quá trình seo. Với những bài viết đã bị xóa thì nó đã được gán với 1 ID nào đó, khi đó bạn tạo bài viết mới mà trùng với ID đã xóa thì công cụ webmaster sẽ báo có sự trùng lặp rất phức tạp. Khi bỏ ID cũng sẽ làm gọn hơn URL của bạn. Vậy thì tại sao chúng ta không cùng tối ưu để có được URL như ý.

 Sau đây minh xin chia sẻ tới các bạn cách để bỏ ID trên url của web Joomla 2.5:

Mở file router.php trong thư mục: components\com_content\router.php bằng một trình soạn thảo nào đó, hoặc copy ra Nopated ++ để bắt đầu chỉnh sửa:

- Tìm đến dòng 27:

$advanced = $params->get('sef_advanced_link', 0);

thay bằng

$advanced = $params->get('sef_advanced_link', 1);

- Tại dòng 208:

$advanced = $params->get('sef_advanced_link', 0);

thay bằng

$advanced = $params->get('sef_advanced_link', 1);

- Tìm đến dòng từ 228 đến 232

if (strpos($segments[0], ':') === false) {
$vars['view'] = 'article';
$vars['id'] = (int)$segments[0];
return $vars;
}


xóa dòng này đi hoặc comment lại ta được

/*if (strpos($segments[0], ':') === false) {
$vars['view'] = 'article';
$vars['id'] = (int)$segments[0];
return $vars;
}*/

Thêm các hướng dẫn ở các phiên bản khác
That is all. I tested this on my Joomla 2.5.4 test site and looks like it works, but I cannot say that it works in all the cases.

Some explanation

If you tried the method described above and it works for you, you could leave it as it is and close this page, but if you interested in some explanation please read below.
As seen from lines 27 and 208 Joomla Content Component uses ‘sef_advanced_link’ parameter, so setting this parameter to ‘1’ eliminates the need for changing this lines. It could be done by adding the following XML to ‘fieldset’ section of administrator\components\com_content\config.xml:
<field name="sef_advanced_link"
    type="radio"
    default="0"
    label="Sef Advanced Mode"
    description="Remove ItemID from Content URL?">
        <option    value="0">JNO</option>
        <option    value="1">JYES</option>
</field>
and then setting ‘Sef Advanced Mode’ to Yes in ‘Article Manager Options’ window:

Please note that setting default=”1″ in XML does not take an effect for some reason.
What concerns lines 228-232, if I leave them uncommented, ID disappears from URL and single articles open fine but when I trying to open a category not linked to some menu item I get “404 – Article not found” error message. I cannot say for sure, but I think that Joomla developers added ‘sef_advanced_link’ parameter but didn’t tested it well enough, so, probably, they will fix this code in future releases.
Chúc các bạn thành công!

1 nhận xét:

  1. May Áo Thun Đồng Phục Công Ty Cao Cấp Tại TpHCM

    May Ao Thun Dong Phuc Cong Ty Cao Cap Tai TpHCM
    -----------------
    Công ty CP Sàn Giao Dịch May Mặc Việt Nam
    A28, Phan Huy Ích, P.15, Tân Bình, Tp.HCM, VN.
    1900 966 933, 08 22 6116 88, 09 02 8998 02, 09 03 04 12 86

    ReplyDelete

Không ngừng HỌC HỎI - SÁNG TẠO và PHÁT TRIỂN.

Châm ngôn sống

Bài viết đáng chú ý

Video hot

Đóng góp - Thắc mắc


Tìm mình trên Facebook: fb.com/conanpt hoặc yahoo: hoabinh_cxx0810 (cứ để lại tin nhắn mình trả lời ngay)
Rất vui được sự đóng góp và cùng giải đáp thắc mắc của các bạn!

Bình luận mới nhất