I'm really struggling to write my .htaccess file properly. I would like the following to happen:
- x.domain.com --> redirect to --> domain.com/index.php?id=x
- If there is a $_GET variable on the original URL, transfer this to the second URL: x.domain.com/?y --> redirect to --> domain.com/index.php?id=x&y
So far, I've managed to get as far as mentioned in the 1st point.
But can't work out where to go next to achieve the 2nd point.
Do I need to write new lines for a separate rule, or amend the current lines?
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !index\.php
RewriteCond %{HTTP_HOST} ^(.+?)\.domain\.com$
RewriteRule .* http://www.domain.com/index.php?id=%1 [L,P]
Any help appreciated.