Add canonical urls anywhere possible

This commit is contained in:
Aleksei Miheev
2014-01-05 13:48:50 +00:00
parent d8ea1def72
commit 2837e76c63
2 changed files with 8 additions and 0 deletions

View File

@@ -350,6 +350,11 @@ function Display()
'current_page' => $_REQUEST['start'] / $modSettings['defaultMaxMessages'] + 1,
'num_pages' => floor($topicinfo['numReplies'] / $modSettings['defaultMaxMessages']) + 1
);
if (isset ($_REQUEST['topicname'])) {
$context['canonical_url'] = "/forum/{$_REQUEST['topicname']}?start={$_REQUEST['start']}";
} else {
$context['canonical_url'] = $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'];
}
// Figure out all the link to the next/prev/first/last/etc. for wireless mainly.
$context['links'] = array(

View File

@@ -94,6 +94,9 @@ function template_main_above()
<link rel="stylesheet" type="text/css" href="http://rock.ru/forum/markitup/sets/bbcode/style.css" />
<link rel="alternate" type="application/rss+xml" title="Новые сообщения в теме" href="http://rock.ru/forum/yarss.php?topic=' . $context['current_topic'] . '" />';
if (!empty($context['canonical_url']))
echo '
<link rel="canonical" href="' . $context['canonical_url'] . '"/>';
// If we're in a board, or a topic for that matter, the index will be the board's index.
if (!empty($context['current_board'])) {