ReWrite Engine Woes

I have something complicated I need to do with my website.

If the user is coming from android or iOS, a GET variable should be added to the URL.



The first part is simple:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (OneMobileUserAgent|AnotherMobileUserAgent|...)
RewriteRule (.*) mobile/$1


This checks for the user agent and sends them somewhere else than where they entered. Changes the URL slightly.



But I need to append a GET variable to this.

I know I could just add "?variable=1" but that is no good because... if it's anything but the first variable there, it needs to use "&variable=1" instead...

I really don't know how to do this.


Basically, if I am on an android device, and I enter the following urls:

http://afar.ws/example.php

It should send me to: http://afar.ws/example.php?device=android

http://afar.ws/example2.php?map=1

It should send me to: http://afar.ws/example2.php?map=1&device=android


Any ideas?


Sorry, I think I've worked out a way to do this through PHP instead which is muh better for me.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75467