`
aliang1990
  • 浏览: 1872 次
社区版块
存档分类
最新评论

zblog robots.txt的正确写法,php版本

阅读更多

zblog robots.txt的正确写法,php版本,robots.txt作为网站的蜘蛛抓取遵循法则,里面可以自定义需要禁止的目录,以及sitemap的附属链接都可以添加

效果:
User-agent: *
Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
Sitemap:meishi/sitemap_index.xml
Sitemap:xx/sitemap.xml

语法就不多说Disallow 禁止,Allow 允许,Sitemap:地图

 

代码:
<?php
header("Content-type: text/plain");
header('HTTP/1.1 200 OK');
$str = 'User-agent: *代码:

<?php
header("Content-type: text/plain");
header('HTTP/1.1 200 OK');
$str = 'User-agent: *
Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
';

$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap_index.xml
';
$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap.xml';
echo $str;

nginx 重定向配置

rewrite ^/robots.txt$ /robots.php last;Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
';

$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap_index.xml
';
$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap.xml';
echo $str;

nginx 重定向配置

rewrite ^/robots.txt$ /robots.php last;




代码:
<?php
header("Content-type: text/plain");
header('HTTP/1.1 200 OK');
$str = 'User-agent: *
Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
';

$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap_index.xml
';
$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap.xml';
echo $str;

nginx 重定向配置

rewrite ^/robots.txt$ /robots.php last;

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics