I have properly set up this site to re-route every bit of traffic from

mywonderfulwebsite.com/folder1/whatever-url.php

to

http://folder1.mywonderfulwebsite.com/whatever-url-as-above.php

Real question is: many occasions, an exterior website links the page with GET parameters, for instance

mywonderfulwebsite.com/folder1/whatever-url.php*?trackingToken=1*

So, question is how you can result in the mod_rewrite pass within the GET parameters towards the "rewrited" url, such as this:

folder1.mywonderfulwebsite.com/whatever-url-as-above.php*?trackingToken=1*

Presently, I am doing the next:

<VirtualHost *>
   ServerName mywonderfulwebsite.com
   ServerAlias www.mywonderfulwebsite.com
   DocumentRoot /var/www/mywonderfulwebsite/
   DirectoryIndex index.html

   <Directory />
      allow from all
      Options +FollowSymlinks -Indexes
   </Directory>

   RewriteEngine On
   RewriteRule    ^/folder1/(.*)?$    http://folder1.mywonderfulwebsite.com/$1&%{QUERY_STRING}    [L,R=301]
</VirtualHost>

This bit of htaccess is awful: for instance, attempting to access this url:

world wide web.mywonderfulwebsite.com/folder1/atextfile.txt

Redirects to

folder1.mywonderfulwebsite.com/atextfile.txt&lifier

Actually, the mod_rewrite appends the trailing &lifier

How do you fix this problem? How you can properly redirecting towards the correct ( also with GET parameters ) url?

Thank you

Just add the [QSA] flag for your other flags to achieve the [Q]uery [S]tring [A]ppended instantly.

[L,R=301,QSA]