gpt4 book ai didi

php - Joomla noindex,遵循PHP代码

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:42:11 26 4
gpt4 key购买 nike

我有一个基于 joomla 的新闻网站,在搜索引擎索引中显示了大量无用的页面。至少作为一个快速修复,直到我可以考虑从头开始重建网站我想在所有页面上实现 NOINDEX、FOLLOW 元标记,但主页和以 .html 结尾的文章页面除外

处理找到的各种代码片段 hereelsewhere我想出了这个:

<?php
if ((JRequest::getVar('view') == "frontpage" ) || ($_SERVER['REQUEST_URI']=='*.html' )) {
echo "<meta name=\"robots\" content=\"index,follow\"/>\n";
} else {
echo "<meta name=\"robots\" content=\"noindex,follow\"/>\n";
}
?>

我对 php 编程还是很陌生,我敢肯定我肯定会犯一些错误,所以我想知道是否有好心人能够将我的代码重温一遍并让我知道如果在我不小心破坏我的网站之前可以使用它。

谢谢,

汤姆

最佳答案

使用 robots.txt 不是更好吗?为此提交文件?

Some major crawlers support an Allow directive which can counteract a following Disallow directive. This is useful when one disallows an entire directory but still wants some HTML documents in that directory crawled and indexed. While by standard implementation the first matching robots.txt pattern always wins, Google's implementation differs in that Allow patterns with equal or more characters in the directive path win over a matching Disallow pattern. Bing uses the Allow or Disallow directive which is the most specific.

In order to be compatible to all robots, if one wants to allow single files inside an otherwise disallowed directory, it is necessary to place the Allow directive(s) first, followed by the Disallow, for example:

Allow: /folder1/myfile.html
Disallow: /folder1/

This example will Disallow anything in /folder1/ except /folder1/myfile.html, since the latter will match first. In case of Google, though, the order is not important.

关于php - Joomla noindex,遵循PHP代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6014008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com