I just found a solution to the problem here:
http://willcodeforcoffee.com/2007/01/31/cakephp-error-500-too-many-redirects/
The .htaccess file in webroot should look like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
instead of this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projectname
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>