Apache htaccess mod重写

So, I am having some issues with my htacces file trying to do some re-write conditions. What I am trying to do is:

There are multiple domains pointed to this web folder. If the domain is anything but example.com I want it to rewrite to example.com UNLESS - the path is /path

Everything is working now except when you go to www.otherexample.com/path

It is hitting the last rule and changing the url to http://dev.otherexample.com/index.php?qs-rewrite=path and causes a redirect loop.

Here's the entire htaccess file

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /

RewriteCond %{HTTP_HOST}          !example\.com$ [NC]
RewriteCond %{REQUEST_URI}        !^/path [NC]
RewriteRule ^.*$                  http://dev.example.com%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI}        ^(.*)//(.*)$
RewriteRule .                     %1/%2 [R=301,L]

RewriteCond %{REQUEST_FILENAME}   !-f
RewriteCond %{REQUEST_FILENAME}   !-d
RewriteRule ^.*$                  index.php?qs-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>

This should be your complete .htaccess:

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTP_HOST}          !example\.com$ [NC]
RewriteCond %{REQUEST_URI}        !^/path [NC]
RewriteCond %{QUERY_STRING}       !qs-rewrite=[^&]+ [NC]
RewriteRule ^                     http://dev.example.com%{REQUEST_URI} [L,R=301,NE]

RewriteCond %{REQUEST_URI}        ^(.*)//(.*)$
RewriteRule .                     /%1/%2 [R=301,L]

RewriteCond %{REQUEST_FILENAME}   !-f
RewriteCond %{REQUEST_FILENAME}   !-d
RewriteRule ^                     /index.php?qs-rewrite=%{REQUEST_URI} [L,QSA]
</IfModule>