codewalker
codewalker

Reputation: 31

Infinite redirect loop with .htaccess

I'm using Zend Framework (not full version, just some components), but I'm having a little problem. I didn't develop the software that I'll give support. When I tried to install, the first page is redirecting until it breaks my server: http://localhost/software/manager/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index/index...

Well I looked at all the code and can't figure out what's wrong. Here's my code:

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ bootstrapClass.php [NC,L]

RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [L]

php_flag magic_quotes_gpc off
php_flag register_globals off
php_value session.auto_start 0
Options -Indexes

http://pastebin.com/DTHrWJYn

Upvotes: 1

Views: 468

Answers (1)

nalply
nalply

Reputation: 28727

The problem is in the line

RewriteRule ^(.*)$ public/$1 [L]

Url Rewriting works this way. After the url got rewritten, the rules are applied again.

To avoid this, use a RewriteCond, for example whether the file does not exist:

RewriteCond %{REQUEST_FILENAME} !-f

Upvotes: 2

Related Questions