Title: RewriteRule results in infinite redirection loop
Tags: .htaccess;mod-rewrite
Question: The title doesn't give justice to the question.
I have a site and I want it to be redirected to a subfolder.
I have this right now:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.net$
RewriteRule ^(.*)$ "http\:\/\/www\.mysite\.net\/subfolder$1" [R=301,L]
The problem is that it results in a infinite redirect loop. It gets to / and redirects it to a subfolder and when it arrives there, it again redirects it.
How do I stop the redirection as soon as it gets to my designated subfolder.
Comment: This should be tagged as mod-rewrite. The title might be - RewriteRule results in infinite redirection loop.

Comment: THanks for that. renaming question and retagged.

Here is the accepted answer: I think I got it right now:
RewriteEngine on
RewriteRule !^(subfolder/) http://www.mysite.net/subfolder/ [L,R]
Got a little inspiration from a deleted answer here:

Here is another answer: Add an exclusion rule for the target.
RewriteEngine on
RewriteRule ^/subfolder - [L]
RewriteCond %{HTTP_HOST} ^mysite.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite.net$
RewriteRule ^(.*)$ "http\:\/\/www\.mysite\.net\/subfolder$1" [R=301,L]

Here is another answer: Also, for the RewriteCond, you can do this:
RewriteCond %{HTTP_HOST} ^(www.)?mysite.net$
to save a line

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2010:00:01/30/10', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<.htaccess><mod-rewrite>', 'Title': 'RewriteRule results in infinite redirection loop', 'ViewCount': 3113, 'id': 2166659, 'user_AboutMe': '<p>PHP / Ruby Developer experienced in various <a href="http://cakephp.org" rel="nofollow noreferrer">php</a> <a href="http://yiiframework.com" rel="nofollow noreferrer">fra</a><a href="http://www.codeigniter.com" rel="nofollow noreferrer">me w</a><a href="http://www.kohanaframework.org" rel="nofollow noreferrer">orks</a> and currently working with <a href="http://rubyonrails.org" rel="nofollow noreferrer">Ruby on Rails</a> and <a href="http://reactjs.org" rel="nofollow noreferrer">ReactJS</a></p>\n\n<p>Javascript Developer, including working knowledge in <a href="http://jquery.com" rel="nofollow noreferrer">jQuery</a> and <a href="http://vuejs.org" rel="nofollow noreferrer">VueJS</a>. I\'ve recently been working with node.js and <a href="http://angularjs.org" rel="nofollow noreferrer">AngularJS</a></p>\n\n<p>Have working knowledge of Adobe Photoshop and Illustrator.</p>\n', 'user_AccountId': 16973.0, 'user_DisplayName': 'Teej', 'user_Reputation': 12604.0, 'user_Views': 1124.0, 'user_id': 37532.0}}