Khi truy cập Sitemap của website https://domain.com/sitemap_index.xml và gặp lỗi (error on line 3 at column 6), (error on line 2 at column 6), (error on line 4 at column 6)… Để xử lý lỗi này, bạn có thể làm theo các bước hướng dẫn của Htdigi dưới đây.

Bước 1: Tạo file whitespacefix.php
Đầu tiên, bạn hãy đăng nhập vào Hosting/VPS của bạn. Tiếp đó, bạn di chuyển vào đúng đường dẫn chứa dữ liệu website và tạo mới một File mới và đặt tên là whitespacefix.php

Tiếp đó bạn chuột phải vào file vừa tạo và chọn Edit File,

Và thêm đoạn code bên dưới vào.
<?php
function ___wejns_wp_whitespace_fix($input) {
$allowed = false;
$found = false;
foreach (headers_list() as $header) {
if (preg_match("/^content-type:s+(text/|application/((xhtml|atom|rss)+xml|xml))/i", $header)) {
$allowed = true;
}
if (preg_match("/^content-type:s+/i", $header)) {
$found = true;
}
}
if ($allowed || !$found) {
return preg_replace("/As*/m", "", $input);
} else {
return $input;
}
}
ob_start("___wejns_wp_whitespace_fix");
?>

Bước 2: Include vào config.php
Bây giờ, các bạn chỉ cần mở File config.php của website, và include file vừa tạo ở Bước 1 vào là xong.
Tiếp đó thêm đoạn bên dưới vào:
include('whitespacefix.php');

Sau khi làm xong, hãy truy cập Sitemap của website theo liên kết https://domain.com/sitemap_index.xml để kiểm tra kết quả. Nếu Sitemap hiển thị như bên dưới là bạn đã xử lý thành công rồi nhé.

Htdigi chúc các bạn thực hiện thành công.!
