burak emre
burak emre

Reputation: 1601

Problem with htaccess redirect (looping)

I worked to do this for 2 hours but finally I gave up.

I have 2 conditions:

1. If user request a php file redirect cms/index.php?request=$1
2. If user request something different from php (png,css,jpg) redirect cms/website/$1

First rule works but I couldn't apply second rule. When user request /cms/style.css, Apache redirect cms/website/style.css and again redirects cms/website/website/style.css and it loops.

My htaccess file is like that:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*\.php) /cms/index.php?request=$1 [L]
RewriteRule (.*\.!(php)) /cms/website/$1 [R,L]

Note: I'm not sure that last regex is true, or not. And it returns 500. error_log output is

"[Tue Aug 16 16:26:11 2011] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace."

Upvotes: 1

Views: 357

Answers (1)

undone
undone

Reputation: 7888

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  !(.*)\.php$
RewriteRule (.*)\.(.*)$ /cms/website/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  (.*)\.php$
RewriteRule (.*)\.php /cms/index.php?request=$1 [L]

Upvotes: 1

Related Questions