Is RewriteRule iterative?

.htccess can be used for url redirection. For example, the following lines in .htaccess will redirect test1.html to test2.html


RewriteEngine On
RewriteRule test1.html test2.html

Now the question: is RewriteRule iterative? To be clear, after test1 is redirected to test2.html, does Apache go through .htaccess from the beginning for test2.html, or simply output test2.html? You must known the [L] directive, which means do not go further in .htaccess. So the following codes in .htaccess won’t redirect test1.html to test3.html, is it right?


RewriteEngine On
RewriteRule test1.html test2.html [L]
RewriteRule test2.html test3.html

Unfortunately, it is wrong, if you type http://domainhostseotool.com/test1.html, it is still redirected to test3.html because RewriteRule is iterative. After test1.html is redirected to test2.html, Apache will take test2.html to go to the same process as test1.html through .htaccess, and this time test2.html is redirected to test3.html. Of course, if there is no [L] in the .htaccess, test1.html is redirected to test3.html in the first run.

Posted in tips of hosting