我有以下.htaccess来重写我的domain.com/ to domain.com/public/
# Rewrite rules for Zend Framework
RewriteEngine on
RewriteRule ^(.*)$ /public/$1 [QSA,L]它工作得很好,但我的日志告诉我,一些机器人试图访问文件robots.txt,但它并不存在。
如果我访问url:http://domain.com/robots.txt不工作
但是如果我访问完整的url,它就可以使用http://domain.com/public/robots.txt。
我在.htaccess中做错了什么?
发布于 2012-03-12 01:41:19
下面的代码解决了我的问题
# Rewrite rules for Zend Framework
RewriteEngine on
Redirect permanent /robots.txt /public/robots.txt
Redirect permanent /favicon.ico /public/favicon.ico
RewriteRule ^(.*)$ /public/$1 [QSA,L]发布于 2011-08-07 10:51:25
看看这篇文章。
http://www.alberton.info/zend_framework_mod_rewrite_shared_hosting.html
但是,正如建议的那样,我建议您移动到另一个主机,以便您的documentRoot指向您的公用文件夹。
发布于 2011-08-07 09:42:00
我想你已经回答了你自己的问题。将robots.txt移到与.htaccess文件相同的目录中。
此外,您应该考虑将您的应用程序/库文件夹上移一级,以防止直接公共访问。
https://stackoverflow.com/questions/6970164
复制相似问题