问题描述
Zend 框架我有如下目录树和 robots.txt 文件,但是当我浏览 www.site.com/robots.txt 时,它说找不到页面错误.我如何告诉 ZF 允许使用 robots.txt?
A.目录树:
网站/应用程序网站/图书馆wwwsite/ZendFramework-1.10.7.tar.gzwwwsite/public.|--- 验证码||--- css|--- js|--- 图片|--- 文件|.htaccess索引.php机器人.txtB..htaccess
重写引擎开启RewriteCond %{REQUEST_FILENAME} -s [OR]RewriteCond %{REQUEST_FILENAME} -l [OR]RewriteCond %{REQUEST_FILENAME} -d重写规则 ^.*$ - [NC,L]重写规则 ^.*$ index.php [NC,L]谢谢问候
解释为什么它对空的 robots.txt 不起作用:
这是因为使用了 rewrite cond -s 来检查文件是否匹配以及文件大小是否大于 0.如果你也想匹配空文件,你可以使用 -f 而不是 -s.
Zend framework i have directory tree as following with robots.txt file, but when i browse www.site.com/robots.txt , it says page not found error. How do i tell ZF that robots.txt is allowed?
A. Directory tree:
wwwsite/application wwwsite/library wwwsite/ZendFramework-1.10.7.tar.gz wwwsite/public . |--- captcha | |--- css |--- js |--- img |--- files | .htaccess index.php robots.txt
B. .htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L]
Thank youRegards
To explain why it doesn't work with empty robots.txt:
It's because rewrite cond -s is used which checks if a file is matched but also if the file is greater than 0 in size. If you want to match empty files as well you can use -f instead of -s.
这篇关于Zend Framework - 将 robots.txt 文件放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!