一個網站已經鏈接到我的網站不正確,在鏈路的末尾添加一個句號:添加額外的點/句號/期導致重複的URL
http://www.example.com/hello-world.
我本來期望這去404頁面,而是加載正確的頁面,而不重定向到有效的URL。
這將在搜索引擎中產生重複的內容問題。
看着其他幾個WordPress站點,它似乎是一個普遍的問題,如果你輸入任意數量的句號或連字符(僅僅是夫妻,我碰到)時,頁面加載正確的內容:
http://www.example.com/hello-------world.......
http://www.example.com/hello-....world-----
是否有其他人遇到過這個問題,並找到解決方案?
我可以設置從鏈接的URL到正確的URL的重定向,但理想情況下我想找到一個解決方案,所以這將不會發生在未來。
UPDATE
我發現,這個問題似乎是由於sanitize_title_with_dashes
功能/wp-includes/formatting.php(線954):
function sanitize_title_with_dashes($title, $raw_title = '', $context = 'display') {
echo "1: " . $title . "<br />";
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
// Remove percent signs that are not part of an octet.
$title = str_replace('%', '', $title);
// Restore octets.
$title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
if (seems_utf8($title)) {
if (function_exists('mb_strtolower')) {
$title = mb_strtolower($title, 'UTF-8');
}
$title = utf8_uri_encode($title, 200);
}
$title = strtolower($title);
$title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = str_replace('.', '-', $title);
echo "2: " . $title . "<br />";
if ('save' == $context) {
// Convert nbsp, ndash and mdash to hyphens
$title = str_replace(array('%c2%a0', '%e2%80%93', '%e2%80%94'), '-', $title);
// Strip these characters entirely
$title = str_replace(array(
// iexcl and iquest
'%c2%a1', '%c2%bf',
// angle quotes
'%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba',
// curly quotes
'%e2%80%98', '%e2%80%99', '%e2%80%9c', '%e2%80%9d',
'%e2%80%9a', '%e2%80%9b', '%e2%80%9e', '%e2%80%9f',
// copy, reg, deg, hellip and trade
'%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2',
), '', $title);
// Convert times to x
$title = str_replace('%c3%97', 'x', $title);
}
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
}
它似乎正在用連字符取代滿分,然後替換多個連字符,然後從URL的末尾修剪連字符。
UPDATE
它似乎並不認爲這是與類別的問題,我不知道爲什麼在網頁/後標題被消毒,以這個水平時,分類並不是...