Reputation: 5059
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?
Upvotes: 2
Views: 2585
Reputation: 5059
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]
Upvotes: 1
Reputation: 59
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.
Upvotes: 3
Reputation: 6431
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.
Upvotes: 0