i具有一个域domain.com
,当不给出任何子域时,它通过.htaccess重写为 subdomain.domain.com/Home/Index
。
这是 - 当然 - 服务器文件系统中的文件,而是路由。该页面是使用Zend2构建的。
由于此转发,crawler 是否找不到位于 public/robots.txt
或ubdomain.domain.com/robots.txt`中的 robots.txt
?
爬行者到底如何处理robots.txt?
您可以通过创建路由器来解决此问题。我参考Matthew Weier O'Phinney以下解决方案。
$route = new Zend_Controller_Router_Route_Static(
'robots.txt'
array(
'module' => 'default',
'controller' => 'index',
'action' => 'robots'
)
);
$router->addRoute('robots.txt', $route);
然后,在您的indexController中创建一个'robotsaction()':
class IndexController extends Zend_Controller_Action
{
// ...
public function robotsAction()
{
// Set content-type header to text/plain
$this->getResponse()->setHeader('Content-Type', 'text/plain');
// perform some logic, add some variables to the view, and
// you're done
}
}