PHP code example of fm-labs / cakephp-seo

1. Go to this page and download the library: Download fm-labs/cakephp-seo library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fm-labs / cakephp-seo example snippets


Configure::write('Seo.RobotsTxt', [
    'sitemapUrl' => '/path/to/custom/sitemap.xml',
    'crawlDelay' => 10,                 // Crawl-delay in seconds
    'rules' => [
        '*' => [                        // Default / All user agents
            '/' => true,                // Allow
        ],
        'google-bot' => [               // User agent
            '/' => true,                // Allow
            '/private' => false,        // Disallow
        ],
        
    ]
])

\Cake\Event\EventManager::instance()->on('Seo.RobotsTxt.build', function($event) {
    $robotsTxt = $event->getSubject();
    
    $rules = []; // put your rules here
    $robotsTxt->addRules($rules);
})