djstarcom/laravel-robots-manager

Laravel robots.txt 管理器

v2.0.1 2021-06-15 07:05 UTC

This package is auto-updated.

Last update: 2024-09-16 13:36:27 UTC


README

Current Release Build Status Code Coverage Code Climate Test Coverage

安装

首先,通过composer安装包

composer require "djstarcom/laravel-robots-manager"

包会自动注册自己。

使用方法

删除项目默认的public/robots.txt

将以下内容添加到您的路由文件中

Route::get('robots.txt', function ()
{
    if (App::environment() == 'production') {
        // If on the live server, serve a nice, welcoming robots.txt.
        RobotsManager::addUserAgent('*');
        RobotsManager::addSitemap('sitemap.xml');
    } else {
        // If you're on any other server, tell everyone to go away.
        RobotsManager::addDisallow('*');
    }

    return Response::make(RobotsManager::generate(), 200, ['Content-Type' => 'text/plain']);
});

有关API使用的参考,请参阅RobotsManager.php

许可证

MIT