If you need to know how to do basic and common URL rewriting, please take a look at our SEO Friendly URL Rewriting post.
We were used to use RewriteRule to match a URL, and then rewrite it. However, RewriteRule will always ignore your query string (GET data) so we need to use RewriteCond to capture the values in the query string.
This is the syntax:
RewriteCond %{QUERY_STRING} ^(.*)$
This case is for you if you’ve rewrote your url this way, for example:
FROM site.com/show.php?id=seo TO site.com/show/seo/
And you WANT to pass or append some GET data using the rewritten URL, like:
site.com/show/seo/?lang=en&source=firefox you want it to append like site.com/show.php?id=seo&lang=en&source=firefox
This is the htaccess rules:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^show/(.*)/$ show.php?id=$1&%1 |
This case is for you if you know specifically or want to control what query string you are going to use.
For example, you only want to match lang=xxx and NOTHING ELSE, for example:
site.com/show/seo/?lang=en&more=1 you want it to append like site.com/show.php?id=seo&lang=en, ignoring other unknown query string.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^lang=(\w+)$
RewriteRule ^show/(.*)/$ show.php?id=$1&lang=%1 |
Similar as Case 2, but tis case we have more query to match.
For example, you only want to match lang=xxx and time=000, for example:
site.com/show/seo/?lang=en&time=100 you want it to append like site.com/show.php?id=seo&lang=en&time=100
RewriteEngine On
RewriteCond %{QUERY_STRING} ^lang=(\w+)&time=(\d+)$
RewriteRule ^show/(.*)/$ show.php?id=$1&lang=%1&time=%2 |


You need to pass [QSA] flag to your rewrite rule to send combined query strings.