Kim*_*cks 5 cakephp robots.txt cakephp-2.0
我在我的现场CakePHP网络应用程序上获得了以下内容:
2014-02-18 04:06:00 Error: [MissingControllerException] Controller class Robots.txtController could not be found.
Exception Attributes: array (
'class' => 'Robots.txtController',
'plugin' => NULL,
)
Request URL: /robots.txt
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我正在使用CakePHP 2.4.2
更新:
这是我的robots.txt.还有什么我应该补充的吗?我把它放进去了webroot.
User-agent: *
Disallow: /admin/
Run Code Online (Sandbox Code Playgroud)
您可能需要编辑 .htaccess 文件(或 /etc/lighttpd/lighttpd.conf 或类似文件,具体取决于您使用的网络服务器)以忽略 /robots.txt 的 url 重写。您必须已经将网络服务器设置为将请求传递给 CakePHP,但遗憾的是它正在将 robots.txt 的请求传递给 CakePHP。您需要将网络服务器配置为不重写 /robots.txt 请求的 url,而是读取文件的内容。
编辑:请记住,我对 nginx 不了解,但尝试这样的事情;
server {
listen 80;
client_max_body_size 5M;
server_name example.com;
root /var/virtual/example.com/webroot;
include common.conf;
include php.conf;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
Run Code Online (Sandbox Code Playgroud)