Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

My logs are FULL of

[Tue Jan 11 10:20:45 2011] [error] [client 99.162.115.123] 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., referer: https://www.domain.com/vehicles/Chevrolet/Uplander/2006

The problem is when I enable LogLevel debug we get HUGE error logs because all of our traffic is SSL. From what I can tell the file doesn't record these errors anymore, either that or it's so buried in SSL logs that I just can't find them.

Here's my .htaccess

Options -indexes
RewriteEngine On

RewriteRule ^battery/([^/]+)$ /browser/product?sku=BATTERY+$1&type=battery
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/product([0-9]+)$ /browser/index.php?make=$1&model=$2&id=$3&%{QUERY_STRING} [L,NC]

RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/([0-9]+)$ /browser/product.php?make=$1&model=$2&year=$3&id=$4&%{QUERY_STRING} [L,NC]

RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /store/product/list.php?make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)/([^/]+)$ /vehicle/make/model/year/list.php?make=$1&model=$2&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)$ /vehicle/make/model/list.php?make=$1&%{QUERY_STRING} [L,NC]
share|improve this question
4  
Enable logging of rewrite rules via RewriteLog and RewriteLogLevel. This should help you track down the problem. –  larsks Jan 11 '11 at 16:50

3 Answers 3

First of all: never ever test in production environment things like this. Install a test server and do one HTTP request there and then look the log. You should be easily able to identify stuff specific to this request.

This debug data is very helpful when solving problems regarding mod_rewrite resolution loops. Basically, it logs every step it is doing and prints the resolution.

RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /store/product/list.php?make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]

This is most likely the rule you want for this case. Instead of this getting effect, the parsing stops to second rule:

RewriteRule ^battery/([^/]+)$ /browser/product?sku=BATTERY+$1&type=battery
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/product([0-9]+)$ /browser/index.php?make=$1&model=$2&id=$3&%{QUERY_STRING} [L,NC]

Since it has [L], last entry. The substitution will stop there. RewriteRules doesn’t care if the URL doesn’t match.

Instead use RewriteConds to do the matching. If they match, the rule will be used, and if not, execution will continue after the rule.

So something like

RewriteCond %{REQUEST_URI} ^vehicles/([^/]+)/([^/]+)/([^/]+)$
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /store/product/list.php?make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]

You could also use params defined in RewriteCond, if you want cleaner rules, with %1.

share|improve this answer

Could you try it without this line ?

RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/product([0-9]+)$ /browser/index.php?make=$1&model=$2&id=$3&%{QUERY_STRING} [L,NC]

Maybe it get confused with the extra parenthesis in product (it's just a guess)

share|improve this answer

Based on your rewriting rules, the one that match your URL is :

RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /store/product/list.php?make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]  

That is rewitten as:

/store/product/list.php?make=Chevrolet&model=Uplander&year=2006&

As larsks and others pointed out, at this point, you should:

Enable logging of rewrite rules via RewriteLog and RewriteLogLevel. This should help you track down the problem. – larsks Jan 11 at 16:50

This way you will see what is happening, and you can then post here the logs to have further help.

Then be aware that mod_rewrite code is executed for each and every HTTP request that accesses a file in or below the directory where the code resides, so this could be the root of your problem.

You can use the following code, which tests if the url does not end in .php and if it doesn't, it will skip the next 6 RewriteRules.

RewriteRule !\.php$ - [S=6]
RewriteRule ^battery/([^/]+)$ /browser/product?sku=BATTERY+$1&type=battery
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/product([0-9]+)$ /browser/index.php?make=$1&model=$2&id=$3&%{QUERY_STRING} [L,NC]  
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)/([0-9]+)$ /browser/product.php?make=$1&model=$2&year=$3&id=$4&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)/([^/]+)/([^/]+)$ /store/product/list.php?make=$1&model=$2&year=$3&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)/([^/]+)$ /vehicle/make/model/year/list.php?make=$1&model=$2&%{QUERY_STRING} [L,NC]
RewriteRule ^vehicles/([^/]+)$ /vehicle/make/model/list.php?make=$1&%{QUERY_STRING} [L,NC]

Hope it helps

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.