ZendFramework .htaccess
I have the following .htaccess to rewrite my domain.com/ to domain.com/public/
# Rewrite rules for Zend Framework
RewriteEngine on
RewriteRule ^(.*)$ /public/$1 [QSA,L]
It works fine but my logs report me that some bots try to access the file robots.txt and it doesn't exists.
If I access the url: http://domain.com/robots.txt doesn't work
but if I access the full url, it works http://domain.com/public/robots.txt
What I am doing wrong in the .htaccess?
我有以下.htaccess将我的domain.com/重写为domain.com/public/ p>
#在
RewriteRule上重写Zend Framework
RewriteEngine的规则^(。*)$ / public / $ 1 [QSA,L]
code> pre>
它工作正常但我的日志报告我有些机器人尝试访问文件robots.txt并且它不存在。 p>
如果我访问网址: http://domain.com/robots.txt 不起作用 p>
但是 如果我访问完整的网址,它可以 http://domain.com/public/robots.txt p>
我在.htaccess中做错了什么? p>
div>
The following code solved my issue
# 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]
I think you've answered your own question. Move robots.txt into the same directory as your .htaccess file.
Also, you should think about moving your application/library folders up one level to keep them from direct public access.
Take a look at this post.
http://www.alberton.info/zend_framework_mod_rewrite_shared_hosting.html
However, as advised, I recommend you to move to another host so your documentRoot points to your public folder.