Mod Rewrite Help

Hello,

I really tried to Google it, but failed (miserably). I want to do two things and can’t seem to combine them… I want to use urls like this:
[COLOR=#B22222]
sub[/COLOR].domain.com/[COLOR=#0000CD]value
[/COLOR]
First thing would be to redirect everything wrong subdomain to the right one:
[COLOR=#0000CD][COLOR=#B22222]
[whatever][/COLOR][/COLOR].domain.com -> [COLOR=#0000CD][COLOR=#B22222]sub[/COLOR][/COLOR].domain.com

Next I’ll have to pass the value to a php file.

sub.domain.com/[COLOR=#0000cd]value[/COLOR] -> sub.domain.com/index.php?var=[COLOR=#0000CD][COLOR=#0000CD]value[/COLOR] [/COLOR]

All I find is tutorials for the value, but the subdomain part is equally crucial in my case and I can’t seem to get both working at the same time :frowning: It either redirects or passes the variable. Does anyone know how to do this? That would be super helpful!!