views:

149

answers:

1

When a RewriteRule is executed by MOD_Rewrite will all the MOD_Rewrite rules be executed again for the newly generated request? Specifically in the following example, will this cause a loop?

RewriteCond Host:  (?:www\.)?mysite\.com
RewriteRule ^(.*)$ $1 [QSA,L]
+3  A: 

In your case, it won't at any rate do a loop. You have the "L" switch on, fixing that particular rule as the last one.

Further, you have to explicitly force the next iteration by using the "N" or "NS" switches, or it will just move through your rule file and stop with the last rule that matches. From the docs:

N (Next iteration)

Forces rewriting engine to modify rule's target and restart rules checking from the beginning (all modifications are saved). Number of restarts is limited by the value specified in the RepeatLimit directive. If this number is exceeded N flag will be simply ignored.

NS (Next iteration of the same rule)

Works like the N flag but restarts rules processing from the same rule (i.e. forces repeat of the rule application). Maximum number of a single rule iterations is given by the RepeatLimit directive. But a number of a single rule repeats does not count for the global number of repeats (i.e. repeats limit for a number of iterations caused by N flag is independent of a number of repeats caused by NS).

Tomalak