Source of file RobotsTxtController.php
Size: 1,345 Bytes - Last Modified: 2021-12-23T10:49:59+00:00
/var/www/docs.ssmods.com/process/src/src/Control/RobotsTxtController.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | <?php namespace Symbiote\Multisites\Control; use Symbiote\Multisites\Model\Site; use Symbiote\Multisites\Multisites; use SilverStripe\Control\Controller; /** * Controller for displaying the robots.txt file for a multisites enabled site. * * <code> * http://site.com/robots.txt * </code> * * @package silverstripe-multisites */ class RobotsTxtController extends Controller { private static $allowed_actions = array( 'robots.txt' => 'index' ); public function index() { $site = Multisites::inst()->getCurrentSiteId(); if(!$site) { return $this->httpError(404); } $page = Site::get()->filter(array( 'ID' => $site )); $page = $page->first(); if(!$page) { return $this->httpError(404); } /* * Trim the RobotsTxt field because it may be an empty string. * and since SilverStripe doesn't ship with a default robots.txt * file, we'll want to return a 404 if there isn't any text for * the site's robots.txt file. */ $text = trim($page->RobotsTxt); if(empty($text)) { return $this->httpError(404); } $this->getResponse()->addHeader('Content-Type', 'text/plain; charset="utf-8"'); return $text; } } |